Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2010
    Location
    California
    Posts
    201
    Thanks
    30
    Thanked 8 Times in 8 Posts

    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."

  • #2
    Regular Coder
    Join Date
    Dec 2010
    Location
    California
    Posts
    201
    Thanks
    30
    Thanked 8 Times in 8 Posts
    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."


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •