I have this HTML code:
PHP Code:
<form method="post" action="register.php">
<table style="margin-top:30px;" cellpadding="3">
<tr><td><strong>Username(<color="red">*</color>):</strong></td><td><input type="text" id="usernameinput" size="30" class="forms" onBlur="user()"><p id="usernamep"></p></td></tr>
<tr><td><strong>Nume complet:</strong></td><td><input type="text" id="nume" size="30" class="forms"><p id="nume"></p></td></tr>
<tr><td><strong>Password(<color="red">*</color>):</strong></td><td><input type="password" id="pass" size="30" class="forms"><p id="pass"></p></td></tr>
<tr><td><strong>Re-type password(<color="red">*</color>):</strong></td><td><input type="password" id="repass" size="30" class="forms"><p id="repass"></p></td></tr>
<tr><td><strong>E-mail(<color="red">*</color>):</strong></td><td><input type="text" id="mail" size="30" class="forms"><p id="mail"></p></td></tr>
<tr><td><strong>Doriti ca e-mailul sa fie ascuns?<strong></td><td><input type="checkbox" id="hidemail"></td></tr>
<br>
<tr><td><input type="submit" value="Inregistreaza-te!" style="margin-left:135px;"></td></tr>
</table>
</form>
Then I got this .js :
Code:
$(document).ready(function user(){
$("#usernameinput").blur(function(){
x=getElementById("usernameinput");
if(x.length<5)
$("#usernamep").html("<color=\"red\">Usernameul trebuie sa contina minim 5 caractere.</color>");
else if(x.length>20)
$("#usernamep").html("<color=\"red\">Usernameul trebuie sa contina maxim 20 de caractere.</color>");
});
});
Could you please explain me what and why it's wrong?
And also, while I'm on the topic, how can I check the mySQL database with jQuery so that I can tell the user(in the register form) whether the username is taken or not.