I have a form which contains 4 text fields when the button is clicked
we should see that atleast one of the textfield should contain the value and the form should get submitted
and the form also contains the Button which of input type too .I want only textbox field values
$("#mybutton").click(function(){
$(":input").each(function(){
if($(this).value!=''){
$("#myform").submit();
}
});
});
You can use
:textfor the selector,.filter()down to ones that have a value and check the.length, like this:this checks if any aren’t empty, and if that’s the case, submits the form once.
And here’s an alternative that checks on
<form>submit, compliments of doug’s comment: