E
E
eldar_web2015-09-19 19:55:30
JavaScript
eldar_web, 2015-09-19 19:55:30

How to check all fields with the same class in jQuery when changing to empty ???

There is an input field (class='.field'), and a disabled button. There is also a change event. Here, at this event, the input field is checked for emptiness, and if it is not empty, then the button will release the lock.
But if we add more inputs (class='.field'), then in that event it is not possible to check all the inputs and unblock the button.
How can I solve the problem???
Here is the code: codepen.io/anon/pen/LpZPXb

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Inchin ☢, 2015-09-19
@eldar_web

But in my case, there are not inputs, but select, and there at the beginning of the option, where value = '0', and now you need not to select this item, otherwise it will be empty. And in this case, how can this code be corrected?
$(document).on('change', '.field', function(){
   $('button').attr(
     'disabled', 
     [].some.call($(".field"), function(e){ return e.value==false })
   );
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question