I’m using Ajax to test if the Username on a Register form is too short.
Right now it just does this:
if (str.length<6)
{
document.getElementById("txtHint").innerHTML="Too short";
return;
}
How do I add an action above that doesn’t let the user submit?
<form action="/insert/insert-user.php" method="post">
<input type="text" name="user" onkeyup="showHint(this.value)"/>
You may try adding a form name and onsubmit event to your form.
You must also repeat the check in php since the user may have Javascript disabled and for security measure: