unkwntech Posted February 9, 2009 Share Posted February 9, 2009 This is my form validation function and the basic form, when I use this code I am getting the following error: Uncaught SyntaxError: Unexpected token on line 41 I added a comment to line 41 to show where it is, what am I doing wrong. ...SNIP... <head> ...SNIP... <script src="jquery.js" type="text/javascript"></script> <script type="text/javascript"> function validateForm() { names = /[\w ]/i; if(!$('firstName').val().match(names)) { //First name does not match the required format $('firstNameError').html() = 'You must enter your first name and it must only contain letters and spcaes!'; } if(!$('lastName').val().match(names)) { //Last name does not match the required format $('lastNameError').html() = 'You must enter your last name and it must only contain letters and spcaes!'; } if(!$('phoneNumber').val().match('/\(?[\d]{3}\)?[ -]?[\d]{3}[ -]?[\d]{4}/')) { //LINE 41 //Phone number does not match any acceptable format $('phoneNumber').html() = 'You must enter you full 10 digit phone number!'; } if($('time1').val() > $('time2')).val()) { //Start time cannnot be before the end time $('timeError').html() = 'The start time must not be after the end time'; } } </script> ...SNIP... <p>If you'd like to get a quote fill out this simple form and we will get back to you as soon as posible.</p> <form name="quote" method="post" action="quoteProcessor.php"> <font color="red"><div id="firstNameError"></div></font> <p>First Name <input type="text" name="firstName" id="firstName"> </p> <font color="red"><div id="lastNameError"></div></font> <p>Last Name <input type="text" name="lastName" id="lastName"> </p> <font color="red"><div id="phoneNumberError"></div></font> <p>Phone Number <input type="text" name="phoneNumber" id="phoneNumber"> </p> <font color="red"><div id="timeError"></div></font> <p>Best Time to Call is between <select name="time1" id="time1"> <option value="7">7am</option> ...SNIP... <option value="21">9pm</option> </select> and <select name="time2" id="time2"> <option value="7">7am</option> ...SNIP... <option value="21">9pm</option> </select> </p> <font color="red"><div id="descriptionError"></div></font> <p>Short Description of your needs<br /> <textarea cols="45" rows="10" name="body" id="body"></textarea> </p> <font color="red"><div id="recaptchaError"></div></font> <p><?php echo recaptcha_get_html($publickey); ?></p> <p> <label> <input type="submit" value="Submit"> </label> </p> </form> ...SNIP... Link to comment https://forums.phpfreaks.com/topic/144449-solved-trouble-with-a-form-validator/ Share on other sites More sharing options...
unkwntech Posted February 9, 2009 Author Share Posted February 9, 2009 There was an extra ) and the line numbers were wrong because of the PHP at the top of the file. Link to comment https://forums.phpfreaks.com/topic/144449-solved-trouble-with-a-form-validator/#findComment-757993 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.