JQuery Not Working

I have a Wordpress Website that I added the following JQuery to.  It stoped working.  I'm not sure why.  What the script does is stops the Form from submitting if certain form fields have not been filled in and gives a message.  At a glance can anyone say why it may have stopped working?  My thoughts are that it is conflicting with something.

<script type="text/javascript">
	 jQuery(function($) {
	 	jQuery.validator.addMethod(
        "regex",
        function(value, element, regexp) {
            var re = new RegExp(regexp);
            return this.optional(element) || re.test(value);
        },
        "Incorrect format; Please check your input."
);

$.noConflict();
jQuery( document ).ready(function( $ )
		$("#getQuote").validate({
errorElement: 'div',
			rules: {
				bike_value: {
					required: true,
					digits: true
				},
				bike_state: {
					required: true,
					maxlength: 2
				},
				email_value: {
					required: true,
					email: true,
                    regex: "^((\"[\\w\\s-]+\")|([\\w-]+(?:\\.[\\w-]+)*)|(\"[\\w\\s-]+\")([\\w-]+(?:\\.[\\w-]+)*))(@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-zA-Z]{2,6}(?:\\.[a-zA-Z]{2})?)$)|(@\\[?((25[0-5]\\.|2[0-4][0-9]\\.|1[0-9]{2}\\.|[0-9]{1,2}\\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\]?$)"
                                          
				}
			},

			messages: {

				bike_value: {
					required: "Please enter the bike value"
				},
				bike_state: {
					required: "Please choose your state"
				},
				email_value: {
                     required: "Please enter an email address",
                     email: "Please enter a valid email address",
                     regex: "Please enter this particular format of email address"
                }		
				
			},
			submitHandler: function(form) {
            form.submit();
        	}
        	
        	
		});

	});
</script>

Open in new window

LVL 7
rgranlundAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ahmed MerghaniSoftware EngineerCommented:
Try this:
<script type="text/javascript">
	 jQuery(function($) {
		jQuery.validator.addMethod(
			"regex",
			function(value, element, regexp) {
				var re = new RegExp(regexp);
				return this.optional(element) || re.test(value);
			},
			"Incorrect format; Please check your input.");
	});

$.noConflict();
jQuery( document ).ready(function( $ ){
		$("#getQuote").validate({
errorElement: 'div',
			rules: {
				bike_value: {
					required: true,
					digits: true
				},
				bike_state: {
					required: true,
					maxlength: 2
				},
				email_value: {
					required: true,
					email: true,
					regex: "^((\"[\\w\\s-]+\")|([\\w-]+(?:\\.[\\w-]+)*)|(\"[\\w\\s-]+\")([\\w-]+(?:\\.[\\w-]+)*))(@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-zA-Z]{2,6}(?:\\.[a-zA-Z]{2})?)$)|(@\\[?((25[0-5]\\.|2[0-4][0-9]\\.|1[0-9]{2}\\.|[0-9]{1,2}\\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\\]?$)"

				}
			},

			messages: {

				bike_value: {
					required: "Please enter the bike value"
				},
				bike_state: {
					required: "Please choose your state"
				},
				email_value: {
					 required: "Please enter an email address",
					 email: "Please enter a valid email address",
					 regex: "Please enter this particular format of email address"
				}		

			},
			submitHandler: function(form) {
			form.submit();
			}


		});

	});
</script>

Open in new window

0
rgranlundAuthor Commented:
@FishBoy. It cleared up the FireBug Error but it does not actually validate the three inputs, email value, state.  Any suggestions?
0
Ahmed MerghaniSoftware EngineerCommented:
Can you post the html form?
0
rgranlundAuthor Commented:
<form id="getQuote" action=" <?php echo $url; ?>/product/bike-insurance/" method="POST">
	<div class="quote-title-cont">
		<span class="quote-title">Get a QUICK QUOTE</span>
	</div>
	<div style="clear"></div>
	<div class="bike-value">
		<input type="text" name="bike_value" id="bike_value" value="<?php if(isset($_POST['bike_value'])) {echo $_POST['bike_value'];} else {echo 'Bike Value';} ?>" onfocus="this.value='';" />
	</div>

	<div style="clear"></div>
	<div class="bike-state">
		<select name="bike_state">
			<div><option value="" style="display:none">Choose State</option></div>
	
			<?php
	// EXECUTE QUERY
			try {
    			$state->execute();
				$result = $state->fetchAll();
		
				foreach ($result as $row) {
    			$id = $row->id;
				$st = $row->state;
    			echo '<option name="bike_state" class="option-center" id="bike_state" value="'.$id.'">'.$st.'</option>';
				}
			}	
			catch(PDOException $a) {
   				echo 'ERROR: ' . $a->getMessage();
			}
			?>
		</select>
	</div>
	
	<div class="email-value">
		<input type="text" name="email_value" id="email_value" value="<?php if(isset($_POST['email_value'])) {echo $_POST['email_value'];} else {echo 'Email Address';} ?>" onfocus="this.value='';" />
	</div>
	
	<div style="clear"></div>
	<div class="quote-submit">
		<input class="submit" type="submit" name="submit" id="submit" value="See My Quote" />
		<input type="hidden" name="get_quote" value="TRUE" />
	</div>
</form>

Open in new window

0
Ahmed MerghaniSoftware EngineerCommented:
It works for me but I have 2 comments on your code:
First, It give me wrong error msg in email field which means you need to revise your code.
Secondly, The bike_state filed options use the same "id" attribute which is incorrect instead use the class. See this link for more info:
http://www.tizag.com/cssT/cssid.php
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.