How to use ParsleyJS 2.* using javascript and not data attributes

巧了我就是萌 提交于 2019-12-20 04:14:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!