我正在尝试验证电子邮件和姓名等等。我正在使用jquery 插件来尝试验证我的表单。但问题是表单甚至没有转到 javascript,它似乎只是重置了。有人可以帮助我吗?
这是html:
<form action method="post" id="register" name="register" class="well form-horizontal">
<label>Username:</label><input type="text" name="username" id="username" />
<label>Email:</label><input type="text" name="email" id="email" />
<label>Password:</label><input type="password" name="password1" id="password1" />
<label>Repeat Password</label><input type="password" name="password2" id="password2" />
<input type="submit" class="btn" value="Submit" />
</form>
这是我的javascript(来自jquery插件):
function myOnComplete () {
alert("does this even work?");
return false;
}
$(document).ready(function() {
$("#register").RSV({
onCompleteHandler: myOnComplete,
rules: [
"required,name,Please enter a username.",
"required,email,Please enter your email address.",
"valid_email,email,Please enter a valid email address.",
"required,password1,Please enter a password.",
"custom_alpha,password1,xxxDDD,The first three characters must be numbers, the last three must be letters."
]
});
return true;
});