0

我正在尝试使用引导程序和 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

4

1 回答 1

1

原来我使用了错误的库 - http://plugins.jquery.com/validate/而不是http://bassistance.de/jquery-plugins/jquery-plugin-validation/。真可惜:/

于 2013-02-06T23:10:25.967 回答