-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not validate immediately #97
Comments
I believe the intent is still to be as close as we can to a drop-in replacement, so aligning our default with the old library seems reasonable. I can't think of any reason we wouldn't always want to capture fields' initial value so we can defer validation until that value has changed. We'd still always validate on submit, of course.
You can specify aspnet-client-validation/src/index.ts Lines 1042 to 1049 in 2c76d35
We can take a closer look at how the old library can be customized, but in the short term we could pretty easily support bootstrapping with Thoughts? |
Thanks!
Yes I did something similar - I saved the initial value to a data attribute, e.g.
I was able to delete so many kludges and workarounds because of that feature. Thanks! I've lodged a docs PR to expose it.
Although that would be nice, but But deferring validating until the field is actually dirty would be a good addition. Without that, some ugly workarounds are still necessary. I haven't written TypeScript in years, so I can't help there, but maybe someone will stumble on this issue for the same reason and help out. Just ping me to get involved and help with testing / documenting, etc. |
Was this addressed in #110? |
I don't think so |
Would like to add my two cents - ideally the logic would be a little bit more complicated than switching validation event to blur. I think it shouldn't do any validation while the user typing for the first time (i.e. until the first blur or submit) but once the validation had failed and user focused back into the input, we should switch back to "input" event to remove the error as soon as the data is valid. upd: I was playing with the code there a little bit trying to implement the desired behavior and noticed that data-val-event value isn't really used - looks like parenthesis are missing in this line: aspnet-client-validation/src/index.ts Line 1092 in b8b9965
|
The original plugin's behaviour is to validate on blur, so that should be the default given that this library is intended to be a drop-in replacement. That said, I suspect we're describing the same thing? |
@lonix1 I've created a PR that adds the new behavior for "delayed validation" using a new option like this:
The default behavior is unchanged and will continue to be a drop-in replacement. Apart of that, I found a bug with Although |
I didn't realise you put it behind a new option, in which case it's all good. I suppose Keith / Phil should decide on the rest. At some point we should also discuss the default behaviour as documented above. |
…nts. Fixed a bug with data-val-event not being respected
#97 Implemented delayed validation by introducing delayedValidation o…
In the original jQuery plugin it was possible to control when validation was activated. By default it would occur on each field's blur (demo).
This library performs validation immediately, i.e. as soon as the user starts typing in a field. That is not standard validation behaviour and leads to poor UX - the user is distracted by validation errors even before submitting the form.
Repro: I wanted to ensure it's not "just me", so:
I can identify these modes of activation:
Is any of this currently possible?
The text was updated successfully, but these errors were encountered: