Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-21-2012, 02:56 AM   PM User | #1
eberdome
Regular Coder

 
Join Date: Dec 2010
Location: California
Posts: 193
Thanks: 28
Thanked 8 Times in 8 Posts
eberdome is an unknown quantity at this point
Contact Form submit issue in IE8 and below

Hey All,

I seem to be having a problem with a contact form's jQuery, but the issue only happens in IE8 and below. As you will see below, the first image shows what the form looks like if there are errors and in all browsers other than IE8 and below experience this same error no matter how many times they click submit. However, in IE8 and below when the user clicks the submit button the first time the first image appears, but when they click it again, those "default" values (Please enter your name, etc) are being submitted and the form defaults to the PHP errors, as shown in the second image. I have posted my code below. Anyone know how to fix this so that it's the same in IE8 and below? Much appreciation in advance!

First Image



Second Image



jQuery code that handles the errors and submitting of the form
Code:
$(document).ready(function(){
                $("div.successContact").hide();
	$("#submitContact").click(function(){
		$(".error").hide();

		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

		var nameVal = $("#name").val();
		if(nameVal == '') {
			$("#name").val('Please enter your name').attr("style","border:1px solid #BB6666;background:#FFEFEF;font-style:italic;color:#999;").focus(function() { $("#name").val('').removeAttr("style","border:1px solid #BB6666;background:#FFEFEF;font-style:italic;color:#999;"); });
			hasError = true;
		}
		
		var emailVal = $("#emailC").val();
		if(emailVal == '') {
			$("#emailC").val('Please enter your email').attr("style","border:1px solid #BB6666;background:#FFEFEF;font-style:italic;color:#999;").focus(function() { $("#emailC").val('').removeAttr("style","border:1px solid #BB6666;background:#FFEFEF;font-style:italic;color:#999;"); });
			hasError = true;
		} 
                else if(emailVal == 'Please enter your email') {
			$("#emailC").html('Please enter your email').attr("style","border:1px solid #BB6666;background:#FFEFEF;font-style:italic;color:#999;").focus(function() { $("#emailC").html('').removeAttr("style","border:1px solid #BB6666;background:#FFEFEF;font-style:italic;color:#999;"); });
			hasError = true;
		}
                else if(!emailReg.test(emailVal)) {	
			$("#emailC").val('Please enter a valid email').attr("style","border:1px solid #BB6666;background:#FFEFEF;font-style:italic;color:#999;").focus(function() { $("#emailC").val('').removeAttr("style","border:1px solid #BB6666;background:#FFEFEF;font-style:italic;color:#999;"); });
			hasError = true;
		}

                var subjectVal = $("#subject").val();
                var bizNameVal = $("#biz_name").val();
                var urlVal = $("#url").val();
                var hearVal = $("#hear").val();
		
		var messageVal = $("#message").val();
		if(messageVal == '') {
			$("#message").html('Please enter your message').attr("style","border:1px solid #BB6666;background:#FFEFEF;font-style:italic;color:#999;").focus(function() { $("#message").html('').removeAttr("style","border:1px solid #BB6666;background:#FFEFEF;font-style:italic;color:#999;"); });
			hasError = true;
		}
                else if(messageVal == 'Please enter your message') {
			$("#message").html('Please enter your message').attr("style","border:1px solid #BB6666;background:#FFEFEF;font-style:italic;color:#999;").focus(function() { $("#message").html('').removeAttr("style","border:1px solid #BB6666;background:#FFEFEF;font-style:italic;color:#999;"); });
			hasError = true;
		}

		if(hasError == false) {
			
			$("#contact-container input.send").after('<img src="http://www.hostoptix.com/images/spinner.gif" alt="" style="position:relative; top:3px; left:15px;" />');
			
			$.post("http://www.hostoptix.com/sendEmail.php",
   				{ name: nameVal, emailC: emailVal, subject: subjectVal, biz_name: bizNameVal, url: urlVal, hear: hearVal, message: messageVal },
   					function(data){
						$("#contact-container").delay('1000').fadeOut('1500');
                                                $("div.successContact").delay('1500').fadeIn('1500').append('<span style="margin-left:150px; color:#FEA92A; font-size:20px;">Thank you, <b style="text-transform:capitalize;">'+nameVal+'</b>!<span style="margin-top:3px; color:#333; font-size:16px;">Your message has been sent.</span><br/><span style="font-size:13px; color:#777;">Please keep an eye on your inbox, we\'ll be sending you an email shortly!<br/><br/>Need to send another message? <a href="/contact.php">Click Here</a></span>');						

                                              	
   					}
				 );
				 	 
		}
		
		return false;
	});						   
});

Thanks in advance!
__________________
"The problem with troubleshooting is that trouble shoots back."
eberdome is offline   Reply With Quote
Old 05-22-2012, 09:30 PM   PM User | #2
eberdome
Regular Coder

 
Join Date: Dec 2010
Location: California
Posts: 193
Thanks: 28
Thanked 8 Times in 8 Posts
eberdome is an unknown quantity at this point
Sorry to bump... really having a hard time figuring this out. Any help would be appreciated, Thanks!
__________________
"The problem with troubleshooting is that trouble shoots back."
eberdome is offline   Reply With Quote
Reply

Bookmarks

Tags
contact, errors, jquery

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:00 AM.


Advertisement
Log in to turn off these ads.