我正在尝试使用bootstrap和jQuery验证创建一个注册页面。不幸的是,当我调用.validate()函数时,Opera会冻结约5秒,验证不起作用。
JS:
$(document).ready(function()
{
$("#register").validate({
rules:{
email:{required:true,email: true},
password:{required:true,minlength: 6}
},
messages:{
email:{
required:"Enter your email address",
email:"Enter valid email address"
},
password:{
required:"Enter your password",
minlength:"Password must be minimum 6 characters"
}
},
errorClass: "help-inline",
errorElement: "span",
highlight: function(element, errorClass, validClass)
{
$(element).parents('.control-group').addClass('error');
},
unhighlight: function(element, errorClass, validClass)
{
$(element).parents('.control-group').removeClass('error');
$(element).parents('.control-group').addClass('success');
}
});
});
HTML:
<form class="form-horizontal" id="register" method='post' action=''>
<fieldset>
<legend>Reg</legend>
<div class="control-group">
<label class="control-label" for="email">Email</label>
<div class="controls">
<input type="text" class="input-medium" id="email" name="email">
</div>
</div>
<div class="control-group">
<label class="control-label" for="password">Password</label>
<div class="controls">
<input type="password" class="input-medium" id="password" name="password">
</div>
</div>
<div class="control-group">
<label class="control-label"></label>
<div class="controls">
<button type="submit" class="btn btn-primary">Go</button>
</div>
</div>
</fieldset>
</form>
知道什么是错的吗?
包含的JS文件:jquery-1.8.3.min.js,bootstrap.min.js,jquery-validate.min.js
答案 0 :(得分:1)
原来我使用了错误的库 - http://plugins.jquery.com/validate/而不是http://bassistance.de/jquery-plugins/jquery-plugin-validation/。真是太遗憾了:/