Is there a reason that the form is still submitting? The validation checks work but if it everything is input correctly, the form submits and the ajax request does not fire.
$("#formRegister").submit(function () {
// Start problem
var mode = $("registerMode").val();
// End problem
var username = $("#registerUsername").val();
var password = $("#registerPassword").val();
var passwordConfirm = $("#registerPasswordConfirm").val();
var avatar = $("#registerAvatar").val();
if (username == 'Username') {
$("#registerError").html('You must enter a username');
} else if (password == 'Password') {
$("#registerError").html('You must enter a password');
} else if (password != passwordConfirm) {
$("#registerError").html('Your passwords did not match');
} else if (avatar == 'Avatar URL') {
$("#registerError").html('You must enter the URL for your combine avatar');
} else {
$.ajax({
type: "POST",
url: "processUsers.php",
data: {
mode: mode,
username: username,
password: password,
avatar: avatar
},
dataType: "JSON",
success: function(data) {
alert('success!');
}
});
}
return false;
});