Preventing Psot till after validation
Hello,
I have an extra button on my page that uses the Axax method to check if a username is taken(This works).
But, I dont want it to submit unless there are no errors on the validate method. Not sure where to put them.
$(document).ready(function()
{$('.error').hide();
$("#CreateAccount").validate(
{
errorPlacement: function(error, element) {
error.insertAfter("#chkAcct" );
},
rules: {
Username: {
required: true,
minlength: 3
}
},
messages: {
Username: {
required: "",
minlength: jQuery.format("At least {0} characters required!")
}
}
});
$('#chkAcct').click(function(){
var name = $('#Username').val();
var data = 'Username='+name;
$.ajax({
type:"POST",
url:"CheckName.php",
data:data,
success:function(html){
$(".error").show();
$(".error").text(html);
}
});
return false;
});
});
Thanks