Function won't work with two out of 20 textboxes

S

SC

I have two identical textboxes and two identical images that go are next to
them. Only the names are different. I have onBlur trigger a function to make
sure the boxes were not left empty. If a textbox was left empty, the image
to the left of the box would be a warning icon. If an entry was made in the
textbox, that image would be a transparent GIF. The function works great on
the other 18 form fields. It only fails to work in IE on the first textbox
and one other textbox further down on the page. All textboxes work with the
function in NS.
Here's the function:

<script language="JavaScript" type="text/javascript">
<!--
// Check for blank text fields and display warning image if blank
function error_check(textfield,checkimage) {
testvalue = textfield.value.toLowerCase();
if (testvalue == 'none' ¦¦ testvalue == 'na' ¦¦ testvalue == 'n/a'){
alert('This fields is required. Please do NOT enter "none", "n/a",
etc.');
textfield.value = "";
textfield.focus();
} else {
s = textfield.value;
re = /\s+/g;
str = s.replace(re, "");
if (str.length > 0){
checkimage.src = "images/spacer.gif";
} else {
checkimage.src = "images/icon_warning.gif";
}
}
}
//-->
</script>

and the form fields are:

<tr>
<td><strong>Password</strong></td>
<td><img src="images/spacer.gif" name="imgpass1" width="17" height="17"
id="imgpass1"></td>
<td><input name="pass1" type="password" id="pass1" style="width:200px"
maxlength="15" onBlur="error_check(this,imgpass1)"></td>
</tr>
<tr>
<td><strong>Re-Enter Password </strong></td>
<td><img src="images/spacer.gif" name="imgpass2" width="17" height="17"
id="imgpass2"></td>
<td><input name="pass2" type="password" id="pass2" style="width:200px"
maxlength="15" onBlur="error_check(this,imgpass2)"></td>
</tr>


I cannot figure out why the first one doesn't work, while the second one
does. I also have one other textbox that this function doesn't seem to work
with. It works fine will the other 18 textboxes on the form. This is only
a problem in IE. Any ideas?

Thanks
 
S

SC

Actually, I fixed the problem with the second textbox that's further down on
the form. The problem seems to be only with the very first textbox, named
"pass1".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top