-
Notifications
You must be signed in to change notification settings - Fork 24
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
Add validateField()
and use it in isFieldValid()
#77
Conversation
let isDropdown = input.tagName.toLowerCase() === 'select'; | ||
let validateEvent = input.dataset.valEvent; | ||
if (isDropdown) { | ||
input.addEventListener('change', cb); | ||
} else if (validateEvent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I'm in the area I noticed the data-val-event
override is being ignored for <select>
. The attribute now takes precedence over the default change
event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is live on NPM! https://www.npmjs.com/package/aspnet-client-validation |
This may need a separate issue but I believe the change from this isn't reflected on README documentation yet and will likely cause some confusion around the pre-validation when used in updated release. Also it would be worth mentioning debounce functionality in that area for future users. Thank you again for this work 🙌 |
Expected
isFieldValid()
behavior is to check a single field, not the whole form. This is technically a breaking change, but the workaround is easy: callvalidateForm()
(orisValid()
) if you want to validate the whole form.isValid()
callsvalidateForm()
unlessprevalidate: false
isFieldValid()
callsvalidateField()
unlessprevalidate: false
In both cases I tried to document that the synchronous return value isn't necessarily accurate if there's async validation.
Would welcome a demo from someone showing off how this can be used.