this post was submitted on 27 Jan 2024
7 points (100.0% liked)

JavaScript

1989 readers
1 users here now

founded 1 year ago
MODERATORS
 

~~ cross-posted from: https://programming.dev/post/9179830 ~~

Hi,

I'm loading some content with XHR (aka Ajax) the loaded input elements that have a invalid value assigned are not checked trough the validation process.

so the CSS styling with :invalid is for example not working etc..

is there a way to force the validation process on those elements ?

edit: Browser is Firefox

Thanks.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 9 months ago (1 children)

Usually validation is only triggered on change or blur events. Changing the value programmatically doesn't trigger these events so you need to trigger them yourself.

[–] [email protected] 1 points 9 months ago (1 children)

Thank you @[email protected] that exactly my question.. how can I trigger the validation process again ?

[–] [email protected] 1 points 9 months ago

Try form.reportValidity() where form is the form element.