Using ASP.NET, why is it that the bassistance.de jQuery validation plugin prevents form submission when using input type="submit" elements, and not html button elements?
The validation fires when using an html button (type="submit") tag, but the form is still submitted.
Is there a way to make the jQuery validation plugin work with html button elements?
A quick example:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript">
$(document).ready(function () {
$("#form1").validate({
rules: {
txtFirstName: {
required: true
}
},
messages: {
txtFirstName: {
required: "* First Name required<br/>"
}
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<input id="txtFirstName" name="txtFirstName" type="text" />
<input id="btnSubmit1" type="submit" runat="server" value="Submit" /> <!-- WORKS! -->
<button it="btnSubmit2" type="submit" runat="server">Submit</button> <!-- DOESN'T WORK -->
</form>
</body>
</html>
itshould beid. Also, which browser(s) are you testing in? IE8-10 seem to work properly. As do Chrome, Opera, and Firefox. (Test: jsfiddle.net/ZQPGH)buttonis atype="submit": jsfiddle.net/vjx9aouc