How to use the parsley.js pattern tag?

后端 未结 1 746
梦毁少年i
梦毁少年i 2021-02-19 08:14

How do I add the attr:data-parsley-pattern=\"\" tag correctly to a input?

I wrote this:



        
1条回答
  •  北荒
    北荒 (楼主)
    2021-02-19 08:54

    Your code seems to work perfectly here: http://jsfiddle.net/c2r4R/

    What you need to know: Parsley validates only empty required fields. Your data-parsley-pattern directive is not applied if field is left empty. You'll need to add a required tag in order to throw an error if field is left empty, and throw another pattern error if field do not match your serial number pattern.

    Best

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