javascript - ParsleyJS custom validator always fails the validation -
https://codepen.io/joshuajazleung/pen/jgeyna
<form data-parsley-validate> <input type="file" name="files" multiple data-parsley-max-files="4"> <button type="submit">submit</button> </form> window.parsley .addvalidator('maxfiles', { requirementtype: 'integer', validatenumber: function(value, requirement) { return true; }, messages: { en: 'maximum number of files 4.', } });
the file input supposed invalid time because validator return true (for testing purposes). when clicked submit button, input isn't valid. wondering why??
it's because value of input not valid number (ever) , defined validatenumber
. need define validatestring
.
to validate files, inspire custom validators example
Comments
Post a Comment