I'm trying to use the jQuery Validation plugin on a form on my website. The form works in FF, Chrome, Opera and Safari. It has yet to work in IE7 or IE8.
Below is a simplified version of my code that seems to work in every browser but IE.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Form</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8/jquery.validate.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var validator = $("form").validate ({
rules: {
first_name: "required"
},
messages: {
first_name: "Enter your firstname"
}
});
});
</script>
</head>
<body>
<form method="post">
<label for="first_name" class="hide">First Name</label>
<input type="text" name="first_name" value="" id="first_name" class="required" />
<button type="submit" id="submit" name="submit">Submit</button>
</form>
</body>
</html>
Edit: We now know that using jquery latest, I was using jQuery v1.6, was the issue. I changed back to v1.5.2 and changed
var validator = $("form").validate ({
to:
$("form").validate ({
Everything is working in IE, now. Thanks.
I think you either need to move back to an earlier version of jquery (1.5.2) or use the newer version of the validation plugin 1.8.0.1.
When you create a new ASP.NET MVC 3 Project in Visual studio, your script folder will by default contain among others:
jquery-1.5.1.min.js
jquery.validate.min.js (which is version 1.8.0)
One of the first things you might want to do is update the jquery version to the latest version, which today is version 1.7.1
After doing this, your client side validation will stop working in Internet Explorer 7 and Internet Explorer 8.
This is because the jquery.validate version is not compatible with jquery versions > 1.6. The solutions is simple, you need to update your version of jquery.validate as well.
You can find the current version 1.9 from Microsoft’s CDN or the latest version from GitHub here:
Microsoft Ajax CDN: http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js
GitHub Jquery Validation: https://github.com/jzaefferer/jquery-validation/downloads
Remember that you can always find the latest javascript library in Microsofts CDN, see the complete list of available libraries here: http://www.asp.net/ajaxlibrary/cdn.ashx
This information is from my blog post about this problem
For what it's worth, I had to upgrade to latest JQuery (1.8.2 at this time) and Validate (1.10) to get around this issue.
I had issues with jquery.validate.js in IE7/IE8. After debugging I noticed the following line was causing the issue (ln 436 in version 1.7):
return $([]).add(this.currentForm.elements)
.filter(":input")
Replace these two lines with something like:
return $(':input', this.currentForm)
That did the trick for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With