How to use ParsleyJS 2.* using javascript and not

2020-04-30 02:24发布

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条回答
别忘想泡老子
2楼-- · 2020-04-30 02:54

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) 
查看更多
登录 后发表回答