I have the following:
<html>
<head>
</head>
<body>
<div>
<form method="post">
<div id="questions">
<label for="question-6">Name of Course:</label>
<input type="text" name="name_of_course[response]" value="" id="question-6" class="required">
<label class="control-label" for="reporting-year">Reporting Year: </label>
<select name="reporting_year" id="reporting-year">
<option value="-1" selected="selected">Select option...</option>
<option value="4">2013-2014</option>
<option value="1">2012-2013</option>
<option value="2">2011-2012</option>
<option value="3">2010-2011</option>
</select>
</div>
<input type="submit" name="submit" value="Save Entry" class="btn">
</form>
</div>
<script src="//code.jquery.com/jquery.js"></script>
<script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js"></script>
<script>
$(function(){
jQuery.validator.addMethod("notEqual", function(value, element, param) {
return this.optional(element) || value !== param;
}, "Please select an option");
$('form').validate({
rules:{
'reporting_year': {
notEqual: "-1"
}
}
});
});
</script>
</body>
</html>
Everyone's favorite browser, IE7 (IE10 w/compatibility really) is reporting the following error in the console:
SCRIPT3: Member not found.
jquery.js, line 2525 character 4
Of course IE8 and above work fine, but my client is using IE7.
Looks like it's a bug with IE10 in compatibility mode as it is reported to work in IE7. But there are some jquery workarounds posted here: http://bugs.jquery.com/ticket/12577
What I found causing the problem is line 35 of jquery.validate.js
this.attr('novalidate', 'novalidate');
Comment out this line and problem is sovled. You could also wrap it with a ( current browser <= ie7) to explictly avoid this line only when ie7 is the broswer.
Update To comment out line only for ie7 you can use the following code:
var ie = (function () {
var undef,
v = 3,
div = document.createElement('div'),
all = div.getElementsByTagName('i');
while (
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
all[0]
);
return v > 4 ? v : undef;
} ());
and then:
if (!ie || ie > 7) {
this.attr('novalidate', 'novalidate');
}
Hello problem from jQuery validation
https://github.com/jzaefferer/jquery-validation/issues/845
Change line 33 of the jquery Validation plugin from:
this.attr( "novalidate", "novalidate" );
to
this.prop( "novalidate", "novalidate" );
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