submitting the form even if the form is in invalid state
Posted
by Abu Hamzah
on Stack Overflow
See other posts from Stack Overflow
or by Abu Hamzah
Published on 2010-05-14T19:55:09Z
Indexed on
2010/05/16
4:20 UTC
Read the original article
Hit count: 297
jQuery
i am using asp.net web forms and i am using bassistance.de jquery validation.. i have bunch of fields in the form and its validatating how it suppose to but its still executing my code behind code, why is it doing that?
here is my code:
form:
<script type="text/javascript">
$(document).ready(function() {
$("#aspnetForm").validate({
rules:
{
<%=txtVisitName.UniqueID %>:
{
maxlength:1,
//minlength: 12,
required: true
}
.................
},
messages:
{
<%=txtVisitName.UniqueID %>:
{
required: "Enter visit name",
minlength: jQuery.format("Enter at least {0} characters.")
}
............
},
success: function(label) {
label.html(" ").addClass("checked");
}
});
$("#aspnetForm").validate();
});
</script>
<div >
<h1>
Page</h1>
<asp:Label runat="server" ID='Label1'>Visit Name:</asp:Label>
<asp:TextBox ID="txtVisitName" runat='server'></asp:TextBox>
............
...............
<button id="btnSubmit" name="btnSubmit" type="submit"> Submit</button>
</div>
and i have a external .js file referencing to my web form page.
$(document).ready(function()
{
$("#btnSubmit").click(function() {
SavePage();
});
});
i have a WebMethod .cs and i have bookmark and it does hitting that line of code even thoug my page is in invalid state.
how would i fix this?
thanks.
© Stack Overflow or respective owner