Form Validation
[CODE]<script type="text/javascript">
function focus()
{
document.homepage.name.focus();
}
function checkall()
{
with(document.homepage)
{
// Check for blank fields
if ((name.value=="")||(password.value=="")||(name.length>20)||(password.length>20))
{
alert("Please complete all fields")
alert("Fields cannot contain more than 20 characters!")
return false;
}
else
{
alert("Welcome!");
return true;
}
}
}
</script>
</head>
<body onLoad="focus()">
<h1>Welcome to the Casino:</h1>
<p>Enter your Username and Password below.</p>
<form name="signin" method="post" action="login.php" onSubmit="return checkall()">
<table border="0">
<tr><td width="120">Username:</td><td><input type="text" name="name"></td></tr>
<tr><td width="120">Password:</td><td><input type="password" name="password"></td></tr>
<tr><td> </td></tr>
<tr><td colspan="2" align="center"><input type="Submit" name="submit" value="Submit"><input type="Reset" name="reset" value="Reset"></td></tr>
</table>
</form>[CODE]
I want an alert to come up if the username or password box is left empty or the amount of characters entered is >20.
When I push submit nothing happens, it just goes to the login.php without validating.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks