S
Skippytpe
Does anyone have an idea why the form validation in the following page
wouldn't be working? I had been using XHTML 1.0 transitional which
allowed me to use the form attribute 'name.' I could then just point
the regular expression test to document.login.frmEmployeeNumber.value
and have it validate. Now that I'm at XHTML 1.1 strict, I can only use
form id's so I *thought* I could pull the elements out as I have below,
but it's not working. Any help would be greatly appreciated.
Thanks,
Justin
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN'
'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>
<html xmlns = 'http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-
1" />
<title>Yellow Design Group - Inventory Control System</title>
<link href="Yellow1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function validateMe(){
var objRegExp = /^[0-9]{6}$/ ;
if (objRegExp.test(document.getElementById('frmEmployeeNumber').value)){
var retType = true;
} else {
alert("Please enter a valid employee number.");
return false;
}
var objRegExp = /^[a-zA-Z0-9]{6}$/ ;
if (objRegExp.test(document.getElementById
('frmEmployeePassword').value)){
var retType = true;
} else {
alert("Please enter a password.");
return false;
}
return retType;
}
</script>
</head>
<body>
<h1>Yellow Design Group - Inventory Control System</h1>
<form id="login" action="Authentication.php" method="get"
onsumbit="javascript:return validateMe();">
<fieldset>
<h5>
<legend>Login :
</legend>
</h5>
<?php
if (isset($error)) {
echo("<strong><font color=red>**Username/Password pair not found.
Please login to continue.**</font></strong><br /><br />");
}
if (isset($error2)) {
echo("<strong><font color=red>**You must login prior to accessing
the Inventory System.**</font></strong><br /><br />");
}
?>
<label for="frmEmployeeNumber"><strong>Employee Number</strong>:
</label>
<input type="text" name="frmEmployeeNumber" id="frmEmployeeNumber"
maxlength="6" />
<br /> <br />
<label for="frmEmployeePassword"><strong>Employee Password</strong>:
</label>
<input type="password" name="frmEmployeePassword"
id="frmEmployeePassword" maxlength="6" />
<br />
<input type="submit" name="Submit" value="Submit" />
<input type="reset" name="Reset" value="Reset" />
</fieldset>
</form>
</body>
</html>
wouldn't be working? I had been using XHTML 1.0 transitional which
allowed me to use the form attribute 'name.' I could then just point
the regular expression test to document.login.frmEmployeeNumber.value
and have it validate. Now that I'm at XHTML 1.1 strict, I can only use
form id's so I *thought* I could pull the elements out as I have below,
but it's not working. Any help would be greatly appreciated.
Thanks,
Justin
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN'
'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>
<html xmlns = 'http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-
1" />
<title>Yellow Design Group - Inventory Control System</title>
<link href="Yellow1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function validateMe(){
var objRegExp = /^[0-9]{6}$/ ;
if (objRegExp.test(document.getElementById('frmEmployeeNumber').value)){
var retType = true;
} else {
alert("Please enter a valid employee number.");
return false;
}
var objRegExp = /^[a-zA-Z0-9]{6}$/ ;
if (objRegExp.test(document.getElementById
('frmEmployeePassword').value)){
var retType = true;
} else {
alert("Please enter a password.");
return false;
}
return retType;
}
</script>
</head>
<body>
<h1>Yellow Design Group - Inventory Control System</h1>
<form id="login" action="Authentication.php" method="get"
onsumbit="javascript:return validateMe();">
<fieldset>
<h5>
<legend>Login :
</legend>
</h5>
<?php
if (isset($error)) {
echo("<strong><font color=red>**Username/Password pair not found.
Please login to continue.**</font></strong><br /><br />");
}
if (isset($error2)) {
echo("<strong><font color=red>**You must login prior to accessing
the Inventory System.**</font></strong><br /><br />");
}
?>
<label for="frmEmployeeNumber"><strong>Employee Number</strong>:
</label>
<input type="text" name="frmEmployeeNumber" id="frmEmployeeNumber"
maxlength="6" />
<br /> <br />
<label for="frmEmployeePassword"><strong>Employee Password</strong>:
</label>
<input type="password" name="frmEmployeePassword"
id="frmEmployeePassword" maxlength="6" />
<br />
<input type="submit" name="Submit" value="Submit" />
<input type="reset" name="Reset" value="Reset" />
</fieldset>
</form>
</body>
</html>