jQuery Validation plugin: How to force a certain phone number format ###-###-####

后端 未结 4 1602
后悔当初
后悔当初 2021-02-10 10:34

I have jQuery Validation plugin on a page. When someone types the phone number into the form field, I want the validator to only recognize a certain format:

###-         


        
4条回答
  •  爱一瞬间的悲伤
    2021-02-10 10:41

    You should try this, and it works well as per your requirement

    jQuery.validator.setDefaults({
      debug: true,
      success: "valid"
    });
    $( "#myform" ).validate({
      rules: {
        field: {
          required: true,
          phoneUS: true
        }
      }
    });
    

提交回复
热议问题