Help with Javascript in a php page
Posted: Sun Jun 20, 2010 4:13 pm
Hi, i am trying to validate a form field using javascript in a php page. But its not working. Here is the code :
Am i missing something here? Kindly help me. Thanks.
Code: Select all
<?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" >
ID:<input type="text" name="id" id="id" size="30" value="" />
<input style="width:19em" id="submit" name="submit" type="submit" value='Validate' />
</form>
<script language="JavaScript" type="text/javascript">
var frmvalidator = new Validator("createaccount");
frmvalidator.addValidation("id","req","Please enter your ID")
frmvalidator.addValidation("id","maxlen=10","Max length for ID is 10");
</script>
</body>
</html>