On 31 March 2011 21:03, Aaron Newton <[email protected]> wrote: >> 1. Can I pass the validator name both with the props class or data- >> validators? > > yes. Using the class is deprecated but still supported. It's a better > practice to use the data- property.
What is the reason behind deprecating the use of the class property? Using data- property leads to non-valid (I mean non standard compliant) html, isn't it? > >> >> 2. If 1==true, then the difference is that if I use class for the >> validator name, then I can use data-validator-properties to pass the >> props? But still I can pass the props directly like this >> class="minLength:10" right? >> And, I guess, can I also use data-validators + data-validator- >> properties together and without class? > > It goes in order. IF you have data-validator-properties it uses that. If not > and you have validatorProps (which is deprecated) it uses that. These are > both standard JSON values. Otherwise it parses the validators list for > properties (which you can put in the data-validators list or in the class > value). But it doesn't let you use all or multiple methods here; it tries > for one, then the next, then the next. > BTW, you can get all these answers by just looking at the code > (https://github.com/mootools/mootools-more/blob/master/Source/Forms/Form.Validator.js#L68). > Not that there's anything wrong with you asking here. > >> >> 3. multiple validators for an element, with properties, and without >> using class. Should I write like this: >> <input data-validators="minLength:10 maxLength:20" />? > > That's fine. > >> >> 4. what if I have multiple validators, that also have some non-name >> property? Should I write like this: >> <input data-validators="validate-date dateFormat:'%d/%m/%Y' validate- >> something-else data:'test' " />? > > Yep: > https://github.com/mootools/mootools-more/blob/master/Source/Forms/Form.Validator.js#L99 -- with regards, Maxim
