I was wondering if anyone could tell me what I am doing wrong...
I have a form on a page that is validated by calling a generic validation
routine (based on the Javascript Bible code) that validates the field. If
the field is incorrect it returns false but doesn't set the focus back on
the incorrect field.
The form is held within a main body page of a FRAME, and the javascript is
held in the main HTML page for the site.
I'm lost as to why this is not working.
Thanks for any help that can be offered.
Darren
Extract from validate.js
var gFrame;
var gField;
// validation routines here
function validate(frame, field, method) {
gFrame = frame;
gField = eval
("window."+frame.name+".document."+field.form.name+"."+field.name);
var args = validate.arguments;
for (iLoop = 2; iLoop < args.length; iLoop++) {
if (!aDispatchLookup[args[iLoop]]()) {
// the select and focus don't seem to work with TAB!!!
gField.select();
gField.focus();
return false;
}
}
return true;
}
Calling page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META CONTENT="Sun, 08 Feb 1998 12:00:01 GMT" HTTP-EQUIV="expires">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK TYPE="text/css" REL="stylesheet" HREF="css.css">
<TITLE></TITLE>
</HEAD>
<BODY LEFTMARGIN="0" TOPMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0">
<FORM METHOD="POST" NAME="TESTFORM">
<INPUT TYPE="text" NAME="phone" SIZE="10" TABINDEX=1
onChange="parent.validate(window,this,'isPosInteger');"><BR>
<INPUT TYPE="text" NAME="next" SIZE="10" TABINDEX=2
onChange="parent.validate(window,this,'isNumber');"><BR>
<INPUT TYPE="text" NAME="anon" SIZE="10" TABINDEX=3
onChange="parent.validate(window,this,'isAnInt');">
<INPUT TYPE="text" NAME="ip" SIZE="15" TABINDEX=4 onChange="parent.validate
(window,this,'isIPv4');">
</FORM>
</BODY>
</HTML>
Start page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="Sun, 08 Feb 1998 12:00:01 GMT" http-equiv=expires>
<LINK TYPE="text/css" REL="stylesheet" HREF="css.css">
<TITLE>WAM Web Front End</TITLE>
<SCRIPT TYPE="text/javascript" SRC="validate.js">
</SCRIPT>
<SCRIPT TYPE="text/javascript" SRC="menu.js">
</SCRIPT>
<SCRIPT TYPE="text/javascript">
// build menu here
deleted
//-->
</SCRIPT>
</HEAD>
<FRAMESET COLS="202,*" BORDER="0" >
<FRAME SRC="mindex.php" SCROLLING="no" NAME="menu" FRAMEBORDER="0"
MARGINWIDTH="0" MARGINHEIGHT="0" NORESIZE="TRUE">
<FRAMESET ROWS="79,*" BORDER="0">
<FRAME SRC="topbar.php" SCROLLING="no" NAME="topbar" FRAMEBORDER="0"
MARGINWIDTH="0" MARGINHEIGHT="0" NORESIZE="TRUE">
<FRAME SRC="body.php" SCROLLING="auto" NAME="body" FRAMEBORDER="0"
MARGINWIDTH="0" MARGINHEIGHT="0" NORESIZE="TRUE">
</FRAMESET>
</FRAMESET>
<NOFRAMES>
<BODY>
This site requires a browser that supports Frames.<BR>
Please try using a HTML 4.0 compliant browser to access this site.
</BODY>
</NOFRAMES>
</HTML>