Exclude invisible Inputs with parsley.js 2.x
Asked Answered
D

3

8

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

Dendrochronology answered 7/4, 2014 at 13:56 Comment(0)
H
14

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)

Heterochromatin answered 8/4, 2014 at 21:5 Comment(3)
sorry it's not working and your current documents shows "data-parsley-excluded" instead "excluded"Irresponsive
The documentation focuses on configuration using the DOM API included in ParsleyJS, since once of the touted features of ParsleyJS is "validation without a single line of JS code!". Of course, the option to use JS is still there. I wish there was more documentation on using JS with ParsleyJS, perhaps in a different version or section of the documetation.Memberg
Parsley options can be configured as HTML data attributes e.g. data-parsley-excluded or they can be configured using JS e.g excluded. Note the JS version doesn't use "data-parsley-"Zildjian
S
1

To disable globally, I added this to the same js page where I set up custom validators, ie:

  window.Parsley.options.excluded = "input[type=button], input[type=submit], input[type=reset], input[type=hidden], [disabled], :hidden" ;

  window.Parsley.addValidator('noemoji', {
    requirementType: 'boolean',
    ...
Shanty answered 31/5, 2020 at 17:43 Comment(1)
I works with parsley.js v2.9.2!Aecium
A
1

With parsley.js v2.9.2, I works with two ways,

First, global config, quote from rossinboulder

window.Parsley.options.excluded = "input[type=button], input[type=submit], input[type=reset], input[type=hidden], [disabled], :hidden" ;

Second, From document, set on form

<form data-parsley-excluded="input[type=button], input[type=submit], input[type=reset], input[type=hidden], [disabled], :hidden">
...
</form>

I didn't find the way to set in global config from document now, that's really strange...

Aecium answered 30/5, 2022 at 10:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.