FALCONSEYE
Programmer
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.
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
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