Jump to content

[SOLVED] field length check


bhavin_85

Recommended Posts

hey guys

 

ive written the following code to check through the lengths that are input into a form, however it doesnt seem to work  ??? i cant figure out where im going wrong

<?
include('config.php');
?>
<html>
<head>
<script type="JavaScript">
function checkInput(){
if((document.registration.username.value.length < 5)||(document.registration.username.value.length < 12)){
  alert ("Please enter a Username between 5 and 12 characters");
  return false;
}
if((document.registration.password.value.length < 5)||(document.registration.password.value.length < 9)){
  alert ("Please enter a Password between 5 and 9 characters");
  return false;
}
}
</script>
<title>Registration</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table align="center" valign="top" width="700" cols="3">
<tr>
<td align="center" colspan="3">
<font size="+5">Online DVD Shop</font>
</td></tr>
<tr><td>
To register for our online shop please complete the following form
</td></tr>
<tr><td>
<form name="registration" method="post" action="" onSubmit="return checkInput();">
Username: <input name="username" type="text"></input></br></br>
Password: <input name="password" type="text"></input></br></br>
Name: <input name="name" type="text"></input></br></br>
Telephone: <input name="telephone" type="text"></input></br></br>
Email: <input name="email" type="text"></input></br></br>
Address: <input name="address" type="text"></input></br></br>
Zipcode: <input name="zipcode" type="text"></input></br></br>
<input type="submit" value="Submit"></input>
</form>
</td></tr>
</table>
</body>
</html>

 

can any1 tell me what im doing wrong?

 

your help is much appreciated

Link to comment
https://forums.phpfreaks.com/topic/45999-solved-field-length-check/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.