Jquery Validation Plugin digits that aren't required not working

后端 未结 1 1030
渐次进展
渐次进展 2020-12-07 04:59

I\'m trying to setup a \"digit\" field using the jQuery Validation plugin

The problem is I don\'t want the digit field to be required, I just want to validate it as

相关标签:
1条回答
  • 2020-12-07 05:30

    This only seems to be a problem with input type="number" fields. It also only works as long as your field name matches your rule declaration, in this case, phoneNumber...

    <input type="text" name="phoneNumber" id="phone" placeholder="Phone (include area code)" value=""/>
    

    DEMO: http://jsfiddle.net/L4crh/


    However, there are various phone number rules you can use that are already included in this plugin as part of the additional-methods.js file

    DEMO 2: http://jsfiddle.net/L4crh/1/


    EDIT:

    The type="number" bug has reportedly been resolved as of jQuery Validate version 1.13.

    https://github.com/jzaefferer/jquery-validation/releases/tag/1.13.0

    0 讨论(0)
提交回复
热议问题