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. frmEmployeeNumb er.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.c ss" rel="stylesheet " type="text/css" />
<script type="text/javascript">
function validateMe(){
var objRegExp = /^[0-9]{6}$/ ;
if (objRegExp.test (document.getEl ementById('frmE mployeeNumber') .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.getEl ementById
('frmEmployeePa ssword').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="Authent ication.php" method="get"
onsumbit="javas cript:return validateMe();">
<fieldset>
<h5>
<legend>Login :
</legend>
</h5>
<?php
if (isset($error)) {
echo("<strong>< font color=red>**Use rname/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="frmEmploye eNumber"><stron g>Employee Number</strong>:
</label>
&nb sp;
<input type="text" name="frmEmploy eeNumber" id="frmEmployee Number"
maxlength="6" />
<br /> <br />
<label for="frmEmploye ePassword"><str ong>Employee Password</strong>:
</label>
<input type="password" name="frmEmploy eePassword"
id="frmEmployee Password" 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. frmEmployeeNumb er.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.c ss" rel="stylesheet " type="text/css" />
<script type="text/javascript">
function validateMe(){
var objRegExp = /^[0-9]{6}$/ ;
if (objRegExp.test (document.getEl ementById('frmE mployeeNumber') .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.getEl ementById
('frmEmployeePa ssword').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="Authent ication.php" method="get"
onsumbit="javas cript:return validateMe();">
<fieldset>
<h5>
<legend>Login :
</legend>
</h5>
<?php
if (isset($error)) {
echo("<strong>< font color=red>**Use rname/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="frmEmploye eNumber"><stron g>Employee Number</strong>:
</label>
&nb sp;
<input type="text" name="frmEmploy eeNumber" id="frmEmployee Number"
maxlength="6" />
<br /> <br />
<label for="frmEmploye ePassword"><str ong>Employee Password</strong>:
</label>
<input type="password" name="frmEmploy eePassword"
id="frmEmployee Password" maxlength="6" />
<br />
<input type="submit" name="Submit" value="Submit" />
<input type="reset" name="Reset" value="Reset" />
</fieldset>
</form>
</body>
</html>
Comment