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 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2009
    Posts
    50
    Thanks
    20
    Thanked 0 Times in 0 Posts

    Exclamation Form not Submitting

    Hi Guys i have a form on the website http://www.wewilbuyyourcar.ie this is a html form that i need to validate and submit and then show a certain page. I think everything is working except for the js any ideas?

    This is my form!!
    Code:
    <div id="contact_form">
    						  <form id="contact" action="process.php">
    							<fieldset>
    
    
    <TR><TD><TABLE BORDER="0" CELLPADDING="3" CELLSPACING="0" WIDTH="50%">
    
    <FORM ACTION="" METHOD="post" name="sellcarform" onsubmit="" >
    <TR><TD CLASS="tableBlueBody" ALIGN="right">* <B>First Name</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT  TYPE="Text" NAME="firstname" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Last Name</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><INPUT TYPE="Text" NAME="lastname"  MAXLENGTH="150"></TD></TR>
    <TR><TD CLASS="tableBlueBody" ALIGN="right"><B>Address</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="AddressLine1" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Email</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><INPUT TYPE="Text" NAME="email" MAXLENGTH="150"></TD></TR>
    <TR><TD CLASS="tableBlueBody" ALIGN="right"><B>City</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="City" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Phone</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><INPUT TYPE="Text" NAME="phone" MAXLENGTH="150"></TD></TR>
    <TR><TD CLASS="tableBlueBody" ALIGN="right"><B>Country</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left">
    
    
    <select name="CountryID">
    	
    		<option value="1"
    						
    		>Albania</option>
    	
    		<option value="2"
    						
    		>Algeria</option>
    	
    		<option value="3"
    						
    		>American Samoa</option> etc...
    	
    </select>
    
    
    </TD><TD CLASS="tableBlueBody" ALIGN="right"><B>Fax</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><INPUT TYPE="Text" NAME="fax" MAXLENGTH="150"></TD></TR>
    
    <TR><TD COLSPAN="4" CLASS="tableBlueBody">&nbsp;</TD></TR>
    <TR><TD CLASS="tableBlueBody" ALIGN="right" VALIGN="top">
    
    
    	<B>Comments</B>
    
    
    
    
    
    </TD><TD COLSPAN="3" CLASS="tableBlueBody" ALIGN="left">
    
    <TEXTAREA NAME="comment" ROWS="7" COLS="45" ></TEXTAREA>
    
    
    </TD></TR>
    
    </TD><TD COLSPAN="5" CLASS="tableBlueBody" ALIGN="left">
    
    
    <TR><TD CLASS="tableBlueBody" ALIGN="right">* <B>Registration Number</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT  TYPE="Text" NAME="regnumber" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Colour</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><INPUT TYPE="Text" NAME="colour"  MAXLENGTH="150"></TD></TR>
    <TR><TD CLASS="tableBlueBody" ALIGN="right">* <B>Car Make</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="carmake" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Has the vehicle been used as a taxi?</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><input type='radio' value="Yes" name='question1' /> Yes <input name='question1' type="radio" value="No" checked /> No</TD></TR>
    <TR><TD CLASS="tableBlueBody" ALIGN="right">* <B>Model</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="model" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Is finance outstanding on the vehicle?</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><input type='radio' value="Yes" name='question2' /> Yes <input name='question2' type="radio" value="No" checked /> No</TD></TR>
    <TR><TD CLASS="tableBlueBody" ALIGN="right">* <B>Milage / Kms</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="milage" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>How did you hear about us?</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><select name="question3"><option value="Other">Other</option><option value="Web">Web</option><option value="Newspaper">Newspaper</option><option value="Radio">Radio</option><option value="Recommended">Recommended</option></select></TD></TR>
    <TR><TD COLSPAN="2" CLASS="tableBlueBody" STYLE="border-bottom : 1px solid #CCCCCC; border-right : 1px solid #CCCCCC;">&nbsp;</TD><TD COLSPAN="2" CLASS="tableBlueBody" STYLE="border-bottom : 1px solid #CCCCCC;">&nbsp;</TD></TR>
    
    
    
    <TR><TD COLSPAN="4" ALIGN="left"><input type="submit" value="Click here to send us your information" class='contactFormSubmit'></TD></TR>
    </FORM></TABLE>
    </TD></TR></TABLE><BR></TD>
    <TD><IMG SRC="images/spacer.gif" WIDTH="8" HEIGHT="1" BORDER="0" ALT=""></TD>
    <TD WIDTH="183" VALIGN="top">
    </TD></TR></TABLE>
    
    							</fieldset>
    						  </form><br />
    					</div><!-- end of #contact_form -->
    This is my process.php file!!
    PHP Code:
    <?php 
        $emailTo 
    'sakura-designs@hotmail.com';
        
    $subject 'We Will Buy Your Car.ie Form Submission';
        
    $firstname=$_POST['firstname'];
        
    $lastname=$_POST['lastname'];
        
    $email=$_POST['email'];
        
    $AddressLine1=$_POST['AddressLine1'];
        
    $City=$_POST['City'];
        
    $phone=$_POST['phone'];
        
    $CountryID=$_POST['CountryID'];
        
    $fax=$_POST['fax'];
        
    $comment=$_POST['comment'];
        
    $regnumber=$_POST['regnumber'];
        
    $colour=$_POST['colour'];
        
    $carmake=$_POST['carmake'];
        
    $question1=$_POST['question1'];
        
    $model=$_POST['model'];
        
    $question2=$_POST['question2'];
        
    $milage=$_POST['milage'];
        
    $question3=$_POST['question3'];
        
        
    $body "First Name: $firstname \n\nLast Name: $lastname \n\nEmail: $email \n\nAddress: $AddressLine1 \n\nCity: $city \n\nPhone: $phone \n\nCountry: $CountryID \n\nFax: $fax \n\nComment: $comment \n\nReg Number: $regnumber \n\nColour: $colour \n\nCar Make: $carmake \n\nQuestion1: $question1 \n\nModel: $model \n\nQuestion2: $question2 \n\nMilage: $milage \n\nQuestion3: $question3";
        
    $headers 'From: '.$name.' <'.$email.'>' "\r\n" 'Reply-To: ' $email;
        
        
    mail($emailTo$subject$body);
        
    header"Location: http://www.wewillbuyyourcar.ie/thankyou.html" );
    ?>
    And this is my contact1.js file!!
    Code:
    $(document).ready( function() {
    	$('.error').hide();
    	$('.but').click( function() {
    		
    		var fname = document.getElementById('firstname');
    		var lname = document.getElementById('lastname');
    		var email = document.getElementById('email');
    		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
    		var AddressLine1 = document.getElementById('AddressLin1');
    		var city = document.getElementById('city');
    		var phone = document.getElementById('phone');
    		var CountryID = document.getElementById('CountryID');
    		var fax = document.getElementById('fax');
    		var comment = document.getElementById('comment');
    		var regnumber = document.getElementById('regnumber');
    		var colour = document.getElementById('colour');
    		var carmake = document.getElementById('carmake');
    		var question1 = document.getElementById('question1');
    		var model = document.getElementById('model');
    		var question2 = document.getElementById('question2');
    		var milage = document.getElementById('milage');
    		var question3 = document.getElementById('question3');
    		
    		if(fname.val() != '' && lname.val() != '') {
    			if(email.val() != '' && emailReg.match.exp) {
    				if(comment != '') {
    					$('#comment_error').show();
    					comment.focus();
    					return false;
    				} else {
    					
    					var dataString = 'name='+ fname + lname +'&email=' + email + '&comment=' + comment;
    					//alert (dataString);return false;
    		
    	  				$ajax({
         					 type: "POST",
         					 url: "process.php",
         					 data: dataString,
         					 success: function() {
         					   $('#contact_form').html("<div id='message'></div>");
         					   $('#message').html("<strong>Contact Form Submitted!</strong>")
         					   .append("<p>We will be in touch soon.</p>")
         					   .hide()
         					   .fadeIn(1500, function() {
         					     jQuery('#message');
         					   });
         					}
        				});
    					
    				}
    			} else {
    				$('#email_error').show();
    				email.focus();
    				return false;
    			}
    		} else {
    			$('#name_error').show();
    			fname.focus();
    			return false;
    		}
    		
    	});
    	
    });
    Thanks for all your help in advance and Merry Christmas

  • #2
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,950
    Thanks
    9
    Thanked 724 Times in 718 Posts
    Haven't looked all through but:

    $ajax

    should be:

    $.ajax

  • Users who have thanked SB65 for this post:

    irishpeck (12-22-2010)

  • #3
    New Coder
    Join Date
    Jun 2009
    Posts
    50
    Thanks
    20
    Thanked 0 Times in 0 Posts
    Thanks ive made that change anyway!! Let me know if theres anything else i can do to make it work

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,914
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Quote Originally Posted by irishpeck View Post
    Thanks ive made that change anyway!! Let me know if theres anything else i can do to make it work
    Have you tried using your error console or Firebug?

    Form validation of the pattern if(fname.val() != '' && lname.val() != '') is barely worthy of the name, and virtually useless, as even a single space, an X or a ? will return false, that is pass the validation. Numeric values, such as zip codes and phone numbers, should be validated as such. This topic has been covered many times before in this forum.

    var city = document.getElementById('city');
    In Internet Explorer, names and IDs are global variables and thus you should NEVER use a global variable or function name which is the same as an HTML element name or ID.
    Last edited by Philip M; 12-22-2010 at 01:45 PM.


  •  

    Posting Permissions

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