Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
43
rated 0 times [  50] [ 7]  / answers: 1 / hits: 6280  / 11 Years ago, wed, january 15, 2014, 12:00:00

Can you test if an input element has the CSS3 :valid or :invalid pseudo-class applied to it with jQuery? I would like to test if the form element passed the CSS validation before enabling a submit button.



Things I tried already that did not work:



if($(#el).is(:valid)) {
//...
}

if($(#el:valid).length == 0) {
//...
}

$(#el).attr(valid)

More From » jquery

 Answers
11

After upgrading to jquery 1.10.2, I can confirm that using the :valid selector now works as expected.



if($(#el).is(:valid)) {
//...
}

[#48665] Wednesday, January 15, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
editha

Total Points: 564
Total Questions: 107
Total Answers: 109

Location: Finland
Member since Fri, Oct 21, 2022
2 Years ago
;