I'm using jQuery Validation Plugin - v1.11.1 and jquery 1.10.2 but below code doesn't work in IE 8. It works fine in IE9 and above and also in other browsers like Chrome.
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="Scripts/jquery_validate.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#btn').click(function() {
$("#form1").validate({
rules: {
<%= txt.UniqueID %>: "required"
},
messages: {
<%= txt.UniqueID %>: "Please enter QTY"
}
});
});
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
ID
<asp:TextBox runat="server" ID="txt" ClientIDMode="Static" />
<asp:Button Text="Test" runat="server" ID="btn" ClientIDMode="Static" />
</asp:Content>
EDITED:
The reason I wrapped the validate() within $('#brn').Click(function(){}) event is that I have another postBack from GridView RowCommand Event.Is there another way to call jquery validate() only when the button is clicked?
Your code incorrectly wraps
.validate()
inside aclick
handler...This is wrong because
.validate()
is only the initialization method of the plugin, so there is no reason to wrap it inside aclick
handler. Theclick
of the submit button is already automatically captured and handled by the plugin.This is the proper way to use the
.validate()
method...Working DEMO using jQuery 1.10.2 and jQuery Validate 1.11.1, tested with IE 81: http://jsfiddle.net/jsDzU/show
1 Tested with a real version of IE 8 installed in Windows XP SP3. Never assume that "IE 8 Mode" in another IE version is an accurate representation of the real thing or an "emulator" - it is not. Microsoft provides free VPC hard drive images for accurate testing in each IE version.