[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

JQuery Form Validation

Posted on 2014-07-10
4
Medium Priority
?
673 Views
Last Modified: 2014-07-10
I have a form on this page: http://spokeinsurance.com/index/
I am using JQuery validation to ensure a bike value, bike state and email address are entered.  However, My form submits without validation happening.  Can someone please tell me what I am doing wrong?
0
Comment
Question by:rgranlund
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:leakim971
ID: 40189167
check my comment in the code
	<script type="text/javascript">
$.noConflict();
	 $(document).ready(function() {
alert("submitted!");
		// validate signup form on keyup and submit
		$("#getQuote").validate({
			rules: {
				bike_value: {
					required: true,
					minlength: 2
				},
				bike_state: {
					required: true,
					minlength: 5
				},
				email_value: {
					required: true,
					email: true
				},

			messages: {

				bike_value: {
					required: "Please enter the bike value",
					minlength: "Your username must consist of at least 2 characters"
				},
				bike_state: {
					required: "Please choose your state",
					minlength: "Your password must be at least 5 characters long"
				},
				email_value: "Please enter a valid email address"
			}
		}}); // HERE THE ERROR, you need two close braces

	});
	</script>

Open in new window

0
 
LVL 7

Author Comment

by:rgranlund
ID: 40189182
I changed it and the validation is still not working.
0
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 40189243
use this instead :

<script type="text/javascript">
	 jQuery(function($) {
		// validate signup form on keyup and submit
		$("#getQuote").validate({
			rules: {
				bike_value: {
					required: true,
					minlength: 2
				},
				bike_state: {
					required: true,
					minlength: 5
				},
				email_value: {
					required: true,
					email: true
				}
			},

			messages: {

				bike_value: {
					required: "Please enter the bike value",
					minlength: "Your username must consist of at least 2 characters"
				},
				bike_state: {
					required: "Please choose your state",
					minlength: "Your password must be at least 5 characters long"
				},
				email_value: "Please enter a valid email address"
				
			},
			submitHandler: function(form) {
            form.submit();
        	}
		});

	});
</script>

Open in new window

0
 
LVL 7

Author Comment

by:rgranlund
ID: 40189280
Your brilliant!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month19 days, 2 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question