PDA

View Full Version : Form validation not working in IE7



wkennyspain
09-17-2012, 10:42 PM
Im using JS to validate form input fields. The code displays appropriate error message and in Firefox and Chrome correctly cancels the form submission. In IE7 the error message also displays but the submission is not cancelled. Any help would be appreciated.

The page is villatorentmiraflores.com

Thanks

jscheuer1
09-18-2012, 04:49 AM
The page is a bit of a mishmash. Among other peculiarities there are 3 form validation scripts on it. One is the on page script which uses the CheckTheForm() function. This is apparently the code you want to take precedence and in most browsers it does. In IE 8 and less one or both of the other two form validation scripts:


<script src="//ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"
type="text/javascript"></script>
<script src="//ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.min.js"
type="text/javascript"></script>

is apparently also having a hand in and interfering with the return value of CheckTheForm or circumventing it somehow. I don't think you're using these, if not, they could and should be removed. That may solve it. But it might be something else on the page that's causing it. Whatever it is appears to be jQuery based, as are those two scripts, so they're prime suspects.

In any case, regardless of whether or not they're the cause and whether or not you remove them, adding this to the bottom of the page just before the closing </body> tag should fix it:


<!--[if lt IE 9]>
<script type="text/javascript">
jQuery(function($){
$(window).load(function(){
$('form[name="villa"]').unbind();
});
});
</script>
<![endif]-->

The browser cache may need to be cleared and/or the page refreshed to see changes.

wkennyspain
09-18-2012, 08:39 AM
Hi John,

Taking the two jquery scripts out has done the job. Thank you so much.