garygreen / dominar

Lightweight bootstrap validator inspired by Laravel
http://garygreen.github.io/dominar/
22 stars 4 forks source link

delay vs delayTriggers #12

Closed stocksp closed 8 years ago

stocksp commented 9 years ago

First Thank a million for your work here!

Could I trouble your for an explanation of delay vs delayTriggers. I don't see an example of delayTriggers?

I would like an email validator to be as unaggressive as possible but still be a little more aggressive than just a change. With a real long email 'somelongName@whereverer.com' , the validator will keep nagging the user until they get to the 'o' in com.

I'm using

email: {
    rules: 'required|email',
      triggers: ['keyup', 'change', 'focusout'],
      delay: 1000
}

and it helps a lot ... but thought maybe there is a better way for this case, maybe delayTriggers. That is keyup would be slow, but change would be fast.

P:)

garygreen commented 9 years ago

delayTriggers is simply an array of what kind of event will trigger a delayed validation. By default it only does a delay during a keyup (to avoid nagging) otherwise the validator will always fire instantly.

I think your strategy of having a high delay value is the best way to be as unaggressive as possible (maybe you could up the delay even more, or not fire the validation during a keyup at all? It will still fire during focusout, change or when submit is pressed).

Not sure what else to suggest, as at some point you need to fire the validator. The options that dominar provides should be enough to give you all possible scenarios?

stocksp commented 9 years ago

so, even though I didn't specify a delayTriggers above, I have one for 'keyup'? If I want the delay to apply to anything besides 'keyup' I need to supply the event in the delayTriggers array (and add it to the triggers array if it isn't there)?

thanks in advance for your patience...

garygreen commented 9 years ago

Correct. Anything in delayTriggers also needs to be in triggers.