I cannot get this basic form validation to submit. I read that the remote is the cause. Is there any way to fix it as I need it to check if a username exists before registering a new user?
I am using jQuery Validation Plugin v1.12.0 if it matters
$("#regForm").validate({
rules: {
username: {
remote: {
url: "username_db.php",
type: "post"
}
}
},
messages: {
username: {
remote: "Username already in use"
}
}
});
PHP:
require_once 'db.php';
if ( $conn = connect() ) {
$row = $conn->prepare("SELECT * FROM users WHERE username = '".$_REQUEST['username']."'");
$row->execute();
$rs = $row->rowCount();
if($rs > 0){
echo 'false';
}else{
echo 'true';
}
}
EDIT:
<form action="" method="post" id="regForm" name="regForm">
<input type="text" name="username">
<input type="submit" name="go" value="GO">
</form>