input validation shouldnt be done in the client side code
Reasons
1. user input cannot be trusted (XSS ,SQL injections attacks)
2. javascript can be turned off
user authentication requires a lot of code to check if the user is trying to crack your system..
if you are trying to write some code just to learn some concepts this is how you authenticate an user..
send username and password to the backend (you can do some input validation using Javascript) you can use html forms..
<form method="POST" action="validateLogin.php">
<input type="text" name="usr" />
<input type="text" name="pwd" />
<input type="submit" name="submit" value="Submit"/>
</form>
you got to do input validation on your server using php..
learn about magic_quotes,input sanitization etc..
//validateLogin.php
usr = $POST["usr"]
pwd = $POST["pwd"]
//check for injection attacks etc etc
mysql_query = "select * form table where usr=$usr and pwd=$pwd"
if(mysql_query) //the user is authentic
//else send him to signup page