问题
Looking in the docs they only offer examples with data attributes, I need to write a different js file for a form and do something like:
$('#myform').parsley(options);
I want to know the available methods in options, and apply validators to inputs and then print custom messages.
It is possible?
回答1:
Yes, just use the camel case equivalent. See also the defaults
$('#myform').parsley({errorClass: 'oups'});
Some javascript methods are in the documentation, others you have to look in the source.
For example, (see this on how to add the corresponding validator):
$('#myform').parsley().addConstraint('isMultiple', 42)
来源:https://stackoverflow.com/questions/28971494/how-to-use-parsleyjs-2-using-javascript-and-not-data-attributes