Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JQuery ajax / validation question.

Status
Not open for further replies.

FALCONSEYE

Programmer
Jul 30, 2004
1,158
US
I am trying to use jquery validation and ajax at the same time. The validation part implements jquery.validate.js. I have the following code.

Code:
<script>
$().ready(function(){

$("#emailReg").validate({
		rules: { 
					email: {
						required: true,
						email: true
					},
					agree: "required"
			},
		messages: {
					email: "<span style='color:red;'>Please enter a valid email address</span>"	,
					agree: "<span style='color:red;'>Please accept our policy</span>"
			}
		});
	
	$('#submit').click(function () { 
	
		var email = $('input[name=email]');
		var data = 'email=' + email.val();
		$.ajax({
					type:"GET",
					url:"act_Vote.cfm",
					data:data,
					success: function(html) {
						if(html == 1) {
							$("#result").html("success");
						} else {
							$("#result").html("Error");
						}
					}
				});
		return false;	

	});		
	
	
});

</script>

The validation never runs. I tried putting the validation after $('#submit').click(function (), that didn't work either. Any help will be appreciated.
thanks in advance

 
Just a reminder
even if validation is working client side always revalidate serverside!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top