Closed niieani closed 8 years ago
@niieani I think this sounds like a good idea but I wonder if this is better suited for a custom element as opposed to be baked in to the validation library. The reason I mention this is that the behavior you describe is a real one but I'm not sure how universal it would be. Does that make sense? Thoughts?
@PWKad I think the behavior can be applied quite universally. Imagine there's a set of matching preset options, or a pattern that a field needs to match. There's a "correction/sanitization" method that takes you from an invalid field value to a valid field value. The correction happens once the user switches to another field, so he is reassured that the corrected output matches his intention. The examples are a plenty:
And probably many more. I think such auto-correction onBlur behavior is better from the UX point of view than either:
It's a thin line between sanitization and validation, but I could imagine some common sanitization components baked in the library, or distributed as plugins.
Thanks for submitting this / commenting on this. At this time we are closing this because we have completely re-written and are deprecating the previous feature set. If you feel this should be re-opened please feel free to review this blog post and submit either again on this repository, or on the new validatejs bridge repository
Thanks again!
As a note this is supported in the latest release.
There are times where it is useful to sanitize the input instead of forcing the user to manually conform to the limitations of the validator on a given field. One example of a use case could be a phone number field - there are many formats a user might give, say, with spaces, while no spaces are allowed - the sanitizator could be run
onBlur
, correcting the field and displaying the change to the user. One could argue that this particular change does not need the user's re-validation (it could be done in the background), however there are situations where the user must be presented with the "autocorrected" field, to confirm that the correction was accurate. One example here is a universalDate
field, where one could type the date in any of the tens of various Date formats - some of which are conflicting with one another - user's confirmation is crucial to validate the field in such case.