I have a javascript function that checks a textbox value and return either true or false regarding it value.
I have several textboxes to check:
<asp:textbox id="txt1" class="tocheck" runat="server />
<asp:textbox id="txt2" class="tocheck" runat="server />
<asp:textbox id="txt3" class="tocheck" runat="server />
and when I press the submit button (Linkbutton1) I check all their values:
$('#LinkButton1').click(function () {
var error = false;
$.each($('.tocheck'), function (i, v) {
error = check($(v).val(), $(this));
});
return error;
});
If one of the calls return true the overall validation must be considered failed and the true value must be kept.
So what I want is prevent the error variable to be set to false when it’s already previously set to true.
Is there any operator or function that controls this?
Thank you.
You can also return
falsein the function to break the each. More information in the documentation : http://api.jquery.com/jQuery.each/