Exclude invisible Inputs with parsley.js 2.x

user3507003 picture user3507003 · Apr 7, 2014 · Viewed 7.4k times · Source

How do I tell the parsley-Instance to exclude not visible form elements?

I found this in the Documentation:

data-parsley-excluded="input[type=button], input[type=submit], input[type=reset], input[type=hidden], [disabled], :hidden"

But I dont now where to set this Option? How can I parse this option to the Constructor?

Further Info: I am binding parsley to my form with jQuery("#formid").parsley();

Thanks a lot. Greets

Answer

guillaumepotier picture guillaumepotier · Apr 8, 2014

Either do:

jQuery("#formid").parsley({ excluded: "input[type=button], input[type=submit], input[type=reset], input[type=hidden], [disabled], :hidden" });

Or

window.ParsleyConfig = { excluded: "input[type=button], input[type=submit], input[type=reset], input[type=hidden], [disabled], :hidden" };
<script src="parsley.js"></script>

(see http://parsleyjs.org/doc/index.html#psly-usage-global-configuration)