Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • A Very Simple & Easy Javascript Form Validation

    • 0
    • 2
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 412
    Comment on it

    Here is a simple way to validate user name and password in an HTML form using java script.

    <html>
    <head>
    <title>
    Login page
    </title>
    </head>
    <body>
    <h1 style="font-family:Arial;text-align="center";font-size:20pt;
    color:#00FF00;">A Very Simple & Easy Javascript Form Validation  </h1>
    <form name="login">
    Username<input type="text" name="userid"/>
    Password<input type="password" name="pswrd"/>
    <input type="button" onclick="check(this.form)" value="Login"/>
    <input type="reset" value="Cancel"/>
    </form>
    <script language="javascript">
    function check(form)/*function to check userid & password*/
    {
    /*the following code checkes whether the entered userid and password are matching*/
    if(form.userid.value == "userid" && form.pswrd.value == "password")
    {
    window.open('target.html')/*opens the target page while Id & password matches*/
    }
    else
    {
    alert("Error Password or Username")/*displays error message*/
    }
    }
    </script>
    </body>
    </html>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: