aspnet-client-validation icon indicating copy to clipboard operation
aspnet-client-validation copied to clipboard

Docs for remove validation feature

Open lonix1 opened this issue 1 year ago • 0 comments

Related to https://github.com/haacked/aspnet-client-validation/pull/110


I'd like to write some docs for the "remove validation" feature. (I'm unfamiliar with the history of the "undebounce" feature, so I'll leave that for another day or another person.)

Comments:

  • I think the demo has the button text toggling the wrong way round. One must click the remove button repeatedly to show the expected text. Very minor point, not important, just something I found.

Questions, I want to know whether I understand the new behaviour:

  • To remove validation from a form, one uses v.remove(formElement)
  • One can readd validation to that form via v.scan(formElement)
  • Validation failure classes remain after removal, e.g. input-validation-error. This is by design as the form's original state could have been server-side errors. If the user wants different behaviour he can reset/remove them.
  • Is there a way to perform the "full reset" idea from this comment, or should one do that manually (possibly by clicking on the form's "reset" button, if it has one)?
  • I'm using document.querySelectorAll('form') or someButton.form to target the form; out of curiosity only (because the library has many cool undocumented features), is it possible to tell which forms the library is currently tracking? UPDATE: a reasonable way is let forms = [...new Set(Array.from(document.querySelectorAll('[data-val]')).map(x => x.form))]; forms.forEach(form => v.remove(form));

Anything else I need to know?

(Sorry for the long list of questions. The new bits are really useful, thanks!)

lonix1 avatar May 09 '24 02:05 lonix1