<form name="loginform" onSubmit="return validateForm();" method="get"> <label>Username</label> <input type="text" name="usr" placeholder="username"> <label>Password</label> <input type="password" name="pword" placeholder="password"> <input type="submit" value="Login"/> </form>
<script> function validateForm() { var un = document.loginform.usr.value; var pw = document.loginform.pword.value; if ((un == "admin") && (pw == "lyndon")) { alert ("Welcome to the system!"); return true; } else { alert ("Login was unsuccessful, wrong username and password"); return false; } } </script>
<html> <title>Login Form </title> <body> <form name="loginform" onSubmit="return validateForm();" method="get"> <label>Username</label> <input type="text" name="usr" placeholder="username"> <label>Password</label> <input type="password" name="pword" placeholder="password"> <input type="submit" value="Login"/> </form> <script> function validateForm() { var un = document.loginform.usr.value; var pw = document.loginform.pword.value; if ((un == "admin") && (pw == "lyndon")) { alert ("Welcome to the system!"); return true; } else { alert ("Login was unsuccessful, wrong username and password"); return false; } } </script> </body> </html>