I have the following function which runs on a change event of a text box:
[code]
function ValidateLocator()
{
if(/d{1}[A-z]|[A-z]{1}d/.test(frmGeneral.txtLocator.value))
{
frmGeneral.submit();
}else{
alert(“You entered an invalid Locator”);
document.frmGeneral.txtLocator.focus();
return(false);
}
It appears to work fine on ie7; however, in ie4 it simply tabs to the other textbox on the screen and doesn’t do anything. Here is the entire page with code. Any ideas?
[code]
<!– #include file=”dbOS.asp” –>
<%
dim ssql
dim intPartID, strLocator, dteDateTime, strSubmission
intPartID = trim(request.form(“txtPartID”))
strLocator = trim(request.form(“txtLocator”))
dteDateTime = now()
if len(intPartID) > 0 then
ssql = “INSERT FullWarehouseScan (PartID, Locator, DateStamp) VALUES (“&intPartID&”, ‘”&strLocator&”‘, ‘”&dteDateTime&”‘)”
‘response.write(ssql)
dbc.execute(ssql)
strSubmission = “yes”
end if
%>
<html>
<head>
<title>Full Warehouse Scan</title>
</head>
<body OnLoad=”SetFocus()”>
<h2><font face=”verdana”>Full Warehouse Scan</h2>
<form id=”frmGeneral” name=”frmGeneral” action=”FullWarehouseScan.asp” method=”post”>
<table border=”0″>
<tr>
<td><font face=”verdana” size=”1″>Part ID</font></td>
<td><input type=”text” id=”txtPartID” name=”txtPartID” size=”20″ onChange=”ValidatePartID()” style=”font-family: Verdana; font-size: 8pt”></td>
</tr>
<td><font face=”verdana” size=”1″>Locator</font></td>
<td><input type=”text” id=”txtLocator” name=”txtLocator” size=”20″ onChange=”ValidateLocator()” style=”font-family: Verdana; font-size: 8pt”></td>
</tr>
</table>
</form>
<%
if strSubmission = “yes” then
response.write(“<font face=Verdana size=2><b>Thank you for your submission</b></font>”)
end if
%>
</body>
</html>
<Script Language=”JavaScript”>
<!–
function SetFocus()
{
document.frmGeneral.txtPartID.focus();
}
function ValidatePartID()
{
if(isNaN(frmGeneral.txtPartID.value))
{
alert(“You must enter a numeric value for a Part ID”);
document.frmGeneral.txtPartID.focus();
return(false);
}
}
function ValidateLocator()
{
if(/d{1}[A-z]|[A-z]{1}d/.test(frmGeneral.txtLocator.value))
{
frmGeneral.submit();
}else{
alert(“You entered an invalid Locator”);
document.frmGeneral.txtLocator.focus();
return(false);
}
}
//–>
</Script>