S
S
SeiLove2015-11-13 10:31:22
JavaScript
SeiLove, 2015-11-13 10:31:22

How to get input this form?

I'm trying to select fields of the current form that have a certain class, but it doesn't work. Maybe someone knows how to do it right?

var form = this.form; 
 var inputs = this.form.elements.hasClass( "valid" );

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Pavlov, 2015-11-13
@dmitry_pavlov

does this code work after page load?

I
Inwork277, 2015-11-13
@Inwork277

hasClass returns true, false, not an object

var inputs = $(form).find("input.valid");

inputs.each(function(){
    alert($(this).val());
});

Y
Yuri, 2015-11-13
@kapitan7830

var inputs = form.querySelectorAll('.valid');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question