Reputation: 397
Here: http://jsfiddle.net/B9r22/22/ I create a form with radio button and text input. I would like to check if in form all inputs are completed. I know check radio button, but text input is not working properly. Can you check my code?
if ($('input[name="age"].value') == null || $('input[name="age"].value') == "") {
alert("is filled");
}
else {
alert("is not filled");
}
Upvotes: 0
Views: 40
Reputation: 6753
Should be
if ($('input[name="age"]').val() == "") {
alert("is filled");
}else {
alert("is not filled");
}
You had set it to input[name="age"].value
, which means get an <input>
element with a name
attribute having value age
and a class value
.
Hope that helps!
Upvotes: 0
Reputation: 2162
You are using it wrong, use
$('input[name="age"]').val() == null
Upvotes: 0
Reputation: 7773
working example: http://jsfiddle.net/B9r22/24/
if ($('input[name=age]').val() === "") {
alert("is not filled");
} else {
alert("is filled");
}
Upvotes: 2