0

我正在使用 colorbox 打开我想使用 jquery.validation 插件的注册表单。问题是,有时验证有效,有时则无效。我尝试在加载到 iframe 的 html 中简单地包含验证,并且尝试使用 onComplete 表示法加载它,如下所示:

       ....
    onComplete:
    $(document).on('blur', '#name', function() {
            alert("Handler for .blur() called.");
        })

我也试过这个:

onComplete:
    $("#name").blur(function() {
    alert("Handler for .blur() called.");
}),

这是我的完整验证尝试——我只得到了必填字段,而不是 minlenths 或自定义消息。

$( "#signupForm" ).validate({
    rules: {
    name: "required",
    username: "required",
    email: {
          required: true,
          email: true   },
    password: {
        required: true,
        minlength: 5  },
    confirmPassword: {
        required: true,
        minlength: 5,
        equalTo: "#password"
    }
     },
    messages: {
        name: "Please enter your full name",
        username: "Please enter your username",
        email: {
            required: "Please enter your email address",
            email: "Email addresses are of the form user@host."
            },
        password: {
            required: "Please provide a password",
            minlength: "Your password must be at least 5 characters long"
        },
        confirmPassword: {
            required: "Please provide a password",
            minlength: "Your password must be at least 5 characters long",
            equalTo: "Please enter the same password as above"
        }
    }

});

最后,这是我表格的一部分——

<input id="name" name="name" type="text" class="text" placeholder="Full Name" required />

……

所以真的有两个问题 - 首先是,为什么只有一部分验证在颜色框中开始,其次,为什么我的“模糊”不起作用?我想使用模糊来做一些 ajax 工作 -

4

0 回答 0