S
Sandy
I have a web page that is used to update user information in a
database. The page displays several rows (each corresponding to a
user record). Each row has an input of type "password" for entering a
password and one for confirming the password--each of the enter
password inputs have the same name but a unique ID (ditto for confirm
password inputs).
The page contains javascript to make sure that the password entered is
The page works with IE and Netscape 6 and higher. With Netscape 4.7x,
we get javascript errors. We found out that Netscape 4.7x does not
support document.getElementById, and also element.id returns
undefined. I'm putting in a simplified version of the form below...
Can somebody tell me how we can code this to work with Netscape 4.7x?
Thanks in advance!
<script language="JavaScript">
var enterCheck = true;
document.hasFocus = null;
var netscape = (navigator.appName == 'Netscape');
function setVal(input)
{
var val = input.value;
var pswdId = input.id;
var cfrmId = pswdId.substring(0,pswdId.length/2);
next = document.getElementById(cfrmId);
if (val != "")
{
enterCheck = false;
if (val.length < 6)
{
alert('Password must be at least 6 characters long');
input.value = "";
enterCheck = true;
if (netscape) setTimeout('document.umfrm.'+input.id+'.focus()',
10);
else input.focus();
}
else
{
enterCheck = false;
if (netscape) setTimeout('document.umfrm.'+next.id+'.focus()',
10);
else next.focus();
}
}
}
function validPassword(input)
{
first = document.getElementById(input.id + input.id);
enterCheck = false;
if (first.value != input.value)
{
alert('Passwords do not match');
input.value = first.value = "";
enterCheck = true;
if (netscape) setTimeout('document.umfrm.'+first.id+'.focus()',
10);
else first.focus();
}
else
{
enterCheck = true;
}
}
</script>
<form method="post" name="umfrm" onSubmit="return check();"
action="xxxx.jsp">
<table>
<tr>
<td>Enter Password:</td>
<td>
<input type="password" name="password" id="nu0nu0" size="10"
maxlength="30" OnBlur="setVal(this);document.hasfocus = null;"
OnFocus="document.hasFocus = this;" onChange="enterCheck=false;">
</td>
<td>Confirm Password:</td>
<td>
<input type="password" name="confirm" id="nu0" size="10"
maxlength="30" OnBlur="validPassword(this);document.hasfocus = null;"
OnFocus="document.hasFocus = this;">
</td>
<td>Dummy:</td>
<td>
<input type="text" name="dummy0" size="10">
</td>
</tr>
<tr>
<td>Enter Password:</td>
<td>
<input type="password" name="password" id="nu1nu1" size="10"
maxlength="30" OnBlur="setVal(this);document.hasfocus = null;"
OnFocus="document.hasFocus = this;" onChange="enterCheck=false;">
</td>
<td>Confirm Password:</td>
<td>
<input type="password" name="confirm" id="nu1" size="10"
maxlength="30" OnBlur="validPassword(this);document.hasfocus = null;"
OnFocus="document.hasFocus = this;">
</td>
<td>Dummy:</td>
<td>
<input type="text" name="dummy1" size="10">
</td>
</tr>
</table>
</form>
database. The page displays several rows (each corresponding to a
user record). Each row has an input of type "password" for entering a
password and one for confirming the password--each of the enter
password inputs have the same name but a unique ID (ditto for confirm
password inputs).
The page contains javascript to make sure that the password entered is
the ID attributes to insure that we're comparingthe correct entries.= 6 chars and also that the two password fields match. The code uses
The page works with IE and Netscape 6 and higher. With Netscape 4.7x,
we get javascript errors. We found out that Netscape 4.7x does not
support document.getElementById, and also element.id returns
undefined. I'm putting in a simplified version of the form below...
Can somebody tell me how we can code this to work with Netscape 4.7x?
Thanks in advance!
<script language="JavaScript">
var enterCheck = true;
document.hasFocus = null;
var netscape = (navigator.appName == 'Netscape');
function setVal(input)
{
var val = input.value;
var pswdId = input.id;
var cfrmId = pswdId.substring(0,pswdId.length/2);
next = document.getElementById(cfrmId);
if (val != "")
{
enterCheck = false;
if (val.length < 6)
{
alert('Password must be at least 6 characters long');
input.value = "";
enterCheck = true;
if (netscape) setTimeout('document.umfrm.'+input.id+'.focus()',
10);
else input.focus();
}
else
{
enterCheck = false;
if (netscape) setTimeout('document.umfrm.'+next.id+'.focus()',
10);
else next.focus();
}
}
}
function validPassword(input)
{
first = document.getElementById(input.id + input.id);
enterCheck = false;
if (first.value != input.value)
{
alert('Passwords do not match');
input.value = first.value = "";
enterCheck = true;
if (netscape) setTimeout('document.umfrm.'+first.id+'.focus()',
10);
else first.focus();
}
else
{
enterCheck = true;
}
}
</script>
<form method="post" name="umfrm" onSubmit="return check();"
action="xxxx.jsp">
<table>
<tr>
<td>Enter Password:</td>
<td>
<input type="password" name="password" id="nu0nu0" size="10"
maxlength="30" OnBlur="setVal(this);document.hasfocus = null;"
OnFocus="document.hasFocus = this;" onChange="enterCheck=false;">
</td>
<td>Confirm Password:</td>
<td>
<input type="password" name="confirm" id="nu0" size="10"
maxlength="30" OnBlur="validPassword(this);document.hasfocus = null;"
OnFocus="document.hasFocus = this;">
</td>
<td>Dummy:</td>
<td>
<input type="text" name="dummy0" size="10">
</td>
</tr>
<tr>
<td>Enter Password:</td>
<td>
<input type="password" name="password" id="nu1nu1" size="10"
maxlength="30" OnBlur="setVal(this);document.hasfocus = null;"
OnFocus="document.hasFocus = this;" onChange="enterCheck=false;">
</td>
<td>Confirm Password:</td>
<td>
<input type="password" name="confirm" id="nu1" size="10"
maxlength="30" OnBlur="validPassword(this);document.hasfocus = null;"
OnFocus="document.hasFocus = this;">
</td>
<td>Dummy:</td>
<td>
<input type="text" name="dummy1" size="10">
</td>
</tr>
</table>
</form>