English 中文(简体)
舱位验证规则
原标题:jquery validation rules
  • 时间:2009-08-25 19:56:22
  •  标签:
  1. My phone validation depends on a checkbox (no, don t contact me via phone). If this is checked, then I will not need run the phone validation. I googled around and found depends function.

  $("#myForm").validate({
  ....
  rules: {
  phone1: {
    required: {
      depends: "!#pri_noPhone:checked"
    },
    number: true,
    minlength:3,
    }

它没有犯错,但仍试图验证电话号码。

  1. Under the rules: how do i make sure that email and confirmEmail are the same? 我rules, and messages separate.
问题回答

试图这样做:

"#phone1": {
   number: true,
   minlength:3,
   required: function(element){
      return ($( #pri_noPhone_wrapper input:checked ).val() ==  True );
   }
}

超文本(在阅读本信后,希望加上包装超文本)

<span id= pri_noPhone_wrapper >
Phone:
<input type="checkbox" name="pri_noPhone" value="what ever" />
</span>

你们会利用这样的手段:

$("#myForm").validate({
      rules: {
          username: {
           email: {
                required:true,
                email:true,
                maxlength:255,
            },
            confirmEmail: {
                required:true,
                equalTo: "#email"
            },
         } 
       }
     })

我认为,你想要利用适当的甄选者辛迪加具体表明你的依赖:

required: {
    depends: "#pri_noPhone:not(:checked)"
}

http://www.ohchr.org。

Steve s对电子邮件的答复:

confirmEmail: {
    required:true,
    equalTo: "#email"
},




相关问题
热门标签