Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get class count on form in jquery?

How can i get the count of my error class on the view ?

I am adding .error class with some span and input controls.But its not necessary the all controls will show at the time of form loading or submitting.

So i just want to get count of the .error class which are showing currently on the form,with the help of jquery.

Can any one help me out on this ?

like image 654
Pawan Avatar asked Jan 20 '26 00:01

Pawan


2 Answers

To get the number of elements that have .error class and are showing currently on the form you can do:

var count = $("form .error:visible").length;
like image 184
letiagoalves Avatar answered Jan 22 '26 14:01

letiagoalves


var count = $('.error').length;

is this what you're after?

like image 35
benhowdle89 Avatar answered Jan 22 '26 13:01

benhowdle89



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!