Count visible and active inputs in my form

1

Well, I know that Jquery Validation does something similar because it only blocks a required field, if it is active, see example (In that case, if you accept "Please agree to our policy" it activates the 3% under% and comboBox becomes active for them as well.)

I'm using the function validate JQuery like this:

function calc(){
    alert($("#meuForm").find(".form").size());
}

In my form I put it to find all fields with find

My big problem is that there are invisible fields and inactive fields, but even so he keeps counting them ..... Any help?

    
asked by anonymous 09.09.2014 / 15:13

2 answers

2

Firstly I do not understand the need to define class="form" for each field but assuming it is a special requirement for the intended, I would like to refer to a form that I find more acceptable using JQuery.

$("#meuForm").find('input[type=text]')

However, going against the requested is possible with the ': visible'

$("#meuForm:visible").each(....);

or

$("#meuForm").not(":visible").each(....);

Finally, I put another way to get all the fields except the 'hidden'!

$(":input:not([type=hidden])") 
    
09.09.2014 / 15:37
3

To get the number of visible and enabled inputs, taking into account that you put the form class in all:

alert($(".form:visible").not(":disabled").length);

Example: link

    
17.09.2014 / 16:12