<script language="JavaScript" type="text/javascript">
function validateform()
{
var flag = 0;
var x = document.createaccount.id.value;
if(x == "")
{
alert("Please enter you ID");
flag = 1;
}
else if(x.length > 10)
{
alert("Max length for ID is 10");
flag = 1;
}
if(flag == 1)
return false;
else
return true;
}
</script>
<?php
session_start();
$pvt_id = session_id();
//if(isset($_POST['submit'])) {
$_SESSION['name'] = 'Jester';
$_SESSION['id'] = $pvt_id ;
//echo $id;
//}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Validation</title>
<script language="JavaScript" src="gen_validatorv31.js" type="text/javascript"></script>
</head>
<body>
<form id="createaccount" name="createaccount" action="register.php" method="post" onSubmit="return validateform();">
ID:<input type="text" name="id" id="id" size="30" value="" maxlength="10" />
<input style="width:19em" id="submit" name="submit" type="submit" value='Validate' />
</form>
</body>
</html>
For the max. length you can also use in html which i have used for you and i have also included it in javascript validation. You can use any of them and if you have any queries then let me know..