javascript - jquery validate with html5 pattern -
how create jquery validate/support html 5 pattern? great if did without specifying pattern on each field.
i know (below), there improve way?
$("form").validate({ rules: { "password": { pattern: /[a-za-z0-9\w]{4,20}/, } } });
see fiddle http://jsfiddle.net/2ma8ec6j/
quote:
"how create jquery validate/support html 5 pattern?"
it does. see below
"it great if did without specifying pattern on each field."
how know pattern goes field if don't specify someplace?
"...is there improve way?"
you can declare some rules via inline html attributes. however, can declare all rules via rules
alternative within .validate()
or .rules()
method.
i don't know if "better" purely matter of opinion, long include additional-methods.js
or pattern.js
file, jquery validate plugin pickup , utilize html5 pattern
attribute.
<input type="text" name="somename" pattern="[a-za-z0-9\w]{4,20}" />
demo: http://jsfiddle.net/flxgz9dn/
see: https://github.com/jzaefferer/jquery-validation/issues/785
javascript jquery html5 jquery-validate
No comments:
Post a Comment