Take the 2-minute tour ×

I have a form that has a required input, but jQuery is saying that the field is valid when it is not. It is strange, because the by the HTML it looks like it has value.

This is the output of three commands in the Chrome console with the textbox totally empty:

// First I ensure that the selector is correct. But I can see that it has value, 
// when it is actually empty.
$('#form_0 input[name=Name]')[0].outerHTML

"<input data-val="true" data-val-length="The field Customer name must be a string with a minimum length of 3 and a maximum length of 20." data-val-length-max="20" data-val-length-min="3" data-val-required="The Customer name field is required." id="Name" name="Name" type="text" value="             Customer 0         " class="valid">"

// jQuery confirms that the field is empty
$('#form_0 input[name=Name]').val()


// but jQuery say that the control is valid :?
$('#form_0 input[name=Name]').valid()


The form and the inputs have been created dynamically with jQuery.

What could be the problem?


share|improve this question
Could you give an URL of the site to test? –  Sangdol Aug 5 '11 at 12:39
Unfortunately not, I'm gonna try to make a proof of concept, and I will put it here. –  vtortola Aug 5 '11 at 13:06

1 Answer 1

up vote 0 down vote accepted

I didn't know I have to call it again when I add inputs dynamically. I guess I have to read more documentation and less examples :P

share|improve this answer

Your Answer


