如何使用ParsleyJS 2. *使用javascript而不是数据属性 [英] How to use ParsleyJS 2.* using javascript and not data attributes

查看:73
本文介绍了如何使用ParsleyJS 2. *使用javascript而不是数据属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看文档,他们只提供数据属性的示例,我需要为表单编写不同的js文件,并执行以下操作:

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);

$('#myform').parsley(options);

我想知道选项中的可用方法,并将验证器应用于输入,然后打印自定义消息。

I want to know the available methods in options, and apply validators to inputs and then print custom messages.

有可能吗?

推荐答案

是的,只需使用相同的驼峰案例。另请参阅默认值

Yes, just use the camel case equivalent. See also the defaults

$('#myform').parsley({errorClass: 'oups'});

一些javascript方法在文档,其他你必须在源代码中查看。

Some javascript methods are in the documentation, others you have to look in the source.

例如,(参见这有关如何添加相应的验证器):

$('#myform').parsley().addConstraint('isMultiple', 42) 

这篇关于如何使用ParsleyJS 2. *使用javascript而不是数据属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆