[thelist] JavaScript Netscape help

Ryan Carmody carmodyryan at hotmail.com
Thu Nov 15 18:49:25 CST 2001


Hi all,

I have an input box on a popup that I would like to validate the info 
entered into.  I would like the validation of the info to take place when a 
user clicks out of the box.  Therefore I'm using onchange, which calls a 
validation function that checks the validity of the info entered.  If the 
info entered is ok, great, if not, have an error message popup and set the 
focus back to the input box.  It work fine in IE, but not in NS.  In NS when 
the focus goes back on the input box with the invalid info if the user 
doesn't change the info the validation function isn't called again like it 
should and does in IE.  It's as if onchange isn't recognized in NS unless 
the info is actually changed.  If anyone can help me here it would be much 
appreciated.  Below is the function,  which is called by onchange, set in 
the input tag.  If someone has a better solution than the approach I'm 
taking that would be good also.

function validateInfo() {
    var x = 0;
	var RSSN=/^[0-9]$/;
   	for (i = 0; i < document.main.test.value.length; i++) {
		if (document.main.test.value.charAt(i) != "," && 
document.main.test.value.charAt(i) != "-" && 
!document.main.test.value.charAt(i).match(RSSN) && 
document.main.test.value.charAt(i) != " ") {
			x = 1;
		}
	}
    if(x == 1) {
       alert("Please only enter numbers, commas, and dashes (-).");
	   document.main.test.focus();
       return(false);
    }
    else {
       return(true);
    }
}

Thanks,
Ryan J. Carmody
carmodyryan at hotmail.com


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp





More information about the thelist mailing list