Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FireFox problems with Javascript Logic

Status
Not open for further replies.

SysTechGuy

Technical User
May 11, 2007
11
US
My company has an online application written in JavaScript where people enter personal information and submit it via the Web. Within the code, information that has to be formatted is sent to functions that test the data to see if it meets certain criteria. For instance, "State" must be entered as only two letters.

There is a problem with these specific fields when erroneous information is entered. The user enters information in the wrong format and then an exception is thrown with an "alert" method. What is suppossed to happen is the user clicks "Okay" on the message pane and then focus is put back on the field that contains the error, thereby not letting the user continue until the data is entered correctly.

What happens instead is that when the "alert" method executes and a message pane appears, the message pane will not disappear when "Okay" is clicked and the user cannot get back to the application. This only happens in FireFox and not in IE7. Here is the function for "State" that tests the data and the html tag that calls the function:

<td valign="top">
<input name="applicantState" type="text" size="5" onblur="stateCheck(document.applicationForm.applicantState);">
</td>

function stateCheck(checkThisState) {
stateString = checkThisState.value;
if ( stateString != "" ) {
stateString = stateString.toUpperCase();
if ( stateString.length == 2 ) {
checkThisState.value = stateString;
}
if ( stateString.length != 2 ) {
checkThisState.focus();
alert("State codes must be two letters only.");
}
}
}

I have tried putting the "checkThisState.focus()" method after the alert statement, which eliminate the problem of the alert message not disappearing, but the focus isn't put on the state field again, which means a user could enter unformatted data.

Again, this is only a problem in FireFox, not Internet Explorer 7. Since a significant portion of our users may use FireFox, I was wondering if there was special code I could enter so FireFox can handle this program logic.

Any input would be greatly appreciated.

 
Pass "this" on your function call:

Code:
<input name="applicantState" type="text" size="5" onblur="stateCheck([!]this[/!])">

In this case, "this" is a reference to the textbox name="applicantState"

[monkey][snake] <.
 
I still get the same result as before. Here is the change I made to the original:

<input name="applicantState" type="text" size="5" onblur="stateCheck(this);">
 
why not simply use the HTML attribute "maxlength"?

Code:
<input name="applicantState" type="text" size="5" maxlength="2" onblur="this.value=this.value.toUpperCase();" />



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
That is a good idea, but there are many other fields in the application that require other formats, like phone number (###-###-####) and zip code (#####) that have to be numbers. The State field is just an example I used since the problem it is having with FireFox is the same as the other fields.


Also, it is more user friendly for an alert message to be used to let the user know what format is required before submitting the form.

This little thing is so frustrating. I do not know why FireFox doesn't handle this simple logic.

I ran the code with the FireFox Error Console on and this was the output when I hit that checkstate function:

Error: too much recursion

Error: uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: chrome://global/content/bindings/dialog.xml :: :: line 135" data: no]

This references "line 135" I opened the file with DreamWeaver and this is line 132 - 136:

if ( document.applicationForm.affiliation.value == "------------" || document.applicationForm.affiliation.value == "-- Back to range selections --" ) {
document.applicationForm.affiliationselections.options.selectedIndex = 0;
document.applicationForm.affiliation.value = "";
toDoOrNo = "No";
}

 
I do not know why FireFox doesn't handle this simple logic.

firefox likely doesn't handle it because of invalid or improper coding, most likely. IE will let things slide, but that's no reason to hold firefox responsible.

what does firefox's error console indicate?



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Well, based on my limited experience with JavaScript, the Error Console appears to indicate that there is a problem passing the argument to the function:

"Error: uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: chrome://global/content/bindings/dialog.xml :: :: line 135" data: no]"

I am not sure of the significance of line 135:

toDoOrNo = "No";

It might be important to note that when I click "Okay" on the alert message box when it appears after entering incorrectly formatted data , that the line "Error: too much recursion" keeps appearing over and over within the Error Console.
 
AHA!

you have a function that is called from a field's onblur event.

that function does a few checks, then sets focus back to the field, [red]then displays an alert box[/red].

see what's happening here? you are setting focus, then removing focus (the alert box). removing the focus (blur) calls the function again, and so on and so forth.

put the focus() call after the alert function call.



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Here are the changes I made:

Code:
function stateCheck(checkThisState) {
	stateString = checkThisState.value;
	if ( stateString != "" ) {
		stateString = stateString.toUpperCase();
		if ( stateString.length == 2 ) {
			checkThisState.value = stateString;
		}
		if ( stateString.length != 2 ) {
			alert("State codes must be two letters only.");
			checkThisState.focus();
		}
	}
}

I switched the "alert" function and "checkThisState.focus() method within the stateCheck function. This eliminates the recursion. However, the focus is not being put back on State after the alert message is cleared. The first few fields in the document are like this:

First Name:
Last Name:
Street Address:
City:
State:
ZIP:

I proceed down to "State" and then add unformatted data and hit the TAB key. The message comes up indicating that it needs to be a two letter state. I click "okay" and instead of the cursor being put back within the "State" box, it is within the "ZIP" box. It seems that focus was not put back on "State".

I am not sure why this is happening.



 
what a freakin pain. here's a workaround:

you will need to ensure that you give each of your elements (or at least your state field) a valid ID.
Code:
if ( stateString.length != 2 ) {
    alert("State codes must be two letters only.");
    setTimeout("document.getElementById('" + checkThisState.id + "').focus();", 1);
}



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Nope. I am still getting the same results as before. The recursion is eliminated, but the focus will not go back to the state field after bad data is entered. Here is what I changed:

Code:
function stateCheck(checkThisState) {
	stateString = checkThisState.value;
	if ( stateString != "" ) {
		stateString = stateString.toUpperCase();
		if ( stateString.length == 2 ) {
			checkThisState.value = stateString;
		}
		if ( stateString.length != 2 ) {
			alert("State codes must be two letters only.");
			setTimeout("document.getElementById('" + checkThisState.id + "').focus();", 1);
		}
	}
}

I don't know if it would be helpful, but here is the full coding for the original application:

Code:
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<title>DuPage Library System Scholarship Application Form</title>

<style type="text/css">
body {font-family: Arial, Helvetica, sans-serif; }
</style>

<script language="javascript">

<!--
stateString = new String();

function setupLists () {
	document.applicationForm.affiliationselections.length = 8;
	document.applicationForm.affiliationselections.options[0].text = "-- Select a range of the alphabet --";
	document.applicationForm.affiliationselections.options[1].text = "A-B";
	document.applicationForm.affiliationselections.options[2].text = "C-E";
	document.applicationForm.affiliationselections.options[3].text = "F-I";
	document.applicationForm.affiliationselections.options[4].text = "J-M";
	document.applicationForm.affiliationselections.options[5].text = "N-Q";
	document.applicationForm.affiliationselections.options[6].text = "R-S";
	document.applicationForm.affiliationselections.options[7].text = "T-W";
}

function selectingList () {

var ABlist = new Array("-- Select your Affiliation –","-- Back to range selections --","------------","Other","------------","Addison Public Library","Addison School District #4","All Saints Catholic Academy","Aurora Central Catholic High School","Aurora Christian Schools","Aurora East School District #131","Aurora Public Library","Aurora School District #129","Aurora University","AVID - Audio Visual Institute of DuPage","Bartlett Public Library District","Batavia Community Unit School District #101","Batavia Public Library District","Benjamin School District #25","Bensenville Community Public Library District","Bensenville Elementary School District #2","Bloomingdale Public Library","Bloomingdale School District #13","BP","BP America, Inc.","Broadview Academy","Butler School District #53");

var CElist = new Array("-- Select your Affiliation –","-- Back to range selections --","------------","Other","------------","C. Berger Group, Inc.","Cantigny First Division Foundation","Carol Stream Public Library","Central Community Unit School District #301","Central DuPage Hospital","College of DuPage","College Preparatory School of America","Community Consolidated School District #89","Community Consolidated School District #93","Community High School District #94","Community Unit School District #200","Delnor-Community Hospital","DeVry University","Driscoll Catholic High School","DuPage High School District #88","DuPage Library System (DLS staff only)","Edward Hospital","Elgin Mental Health Center","Engineering Systems, Inc.");

var FIlist = new Array("-- Select your Affiliation –","-- Back to range selections --","------------","Other","------------","Fenton Community High School District #100","Fermilab","Fermilab, Leon M. Lederman Science Education Center","Fox Valley Lutheran Academy","Franklin Park Public Library District","Franklin Park Public School District #84","Geneva Community Unit School District #304","Geneva Public Library District","Glen Ellyn District #41","Glen Ellyn Public Library","Glenbard Township High School District #87","GlenOaks Hospital","Glenside Public Library District","Glenwood School","Helen M. Plum Memorial Library","Illinois Department of Corrections School District #428","Illinois Institute of Technology, Daniel F. & Ada L. Rice Campus","Illinois Mathematics and Science Academy","Illinois School District U-46","Immanuel Lutheran School","Indian Prairie Community Unit School District #204","Islamic Foundation School","Itasca Community Library","Itasca School District #10");

var JMlist = new Array("-- Select your Affiliation –","-- Back to range selections --","------------","Other","------------","Joint Commission of Accreditation of Healthcare Organizations","Kane County Law Library","Kaneland Community Unit School District #302","Kaneville Public Library District","Keeneyville Elementary School District #20","Lake Park High School District #108","Learning Point Associates","Leyden High School District #212","Lombard Elementary School District #44","Mannheim School District #83","Marianjoy Rehabilitation Hospital","Marmion Academy","Marquardt School District #15","McDonalds Corporation","McDonnell Investment Management, LLC","Medinah School District #11","Messenger Public Library of North Aurora","Montini Catholic High School","Mooseheart High School");

var NQlist = new Array("-- Select your Affiliation –","-- Back to range selections --","------------","Other","------------","Nalco Company","Naperville Community Unit School District #203","Naperville Public Library","Naperville Sun/Sun Publications, Inc.","National Safety Council","National University of Health Sciences","Nicor Gas","North Central College","North East Multi-Regional Training","Northern Seminary","Northwestern Business College, Naperville Campus","Oak Brook Public Library","Packer Engineering, Inc.","Poplar Creek Public Library District","Provena Mercy Center","Provena St. Joseph Hospital","Queen Bee School District #16");

var RSlist = new Array("-- Select your Affiliation –","-- Back to range selections --","------------","Other","------------","Robert Morris College","Rosary High School","Roselle Public Library District","Roselle School District #12","Rush-Copley Medical Center","Salt Creek Elementary School District #48","St. Charles Community Unit School District #303","St. Charles Public Library District","St. Francis High School","St. James the Apostle School","St. John Lutheran School","St. John the Baptist School","St. Matthew School","St. Patrick Catholic School","St. Paul's Lutheran School","St. Petronille School","St. Pius X School","St. Walter School","Ss. Peter and Paul School","Sugar Grove Public Library District");

var TWlist = new Array("-- Select your Affiliation –","-- Back to range selections --","------------","Other","------------","Technology Center of DuPage","Theosophical Society in America","Town & Country Public Library District","Trinity Lutheran School","University Health System Consortium","Villa Park Elementary School District #45","Villa Park Public Library","Warrenville Public Library District","Waubonsee Community College","West Chicago Elementary School District #33","West Chicago Public Library District","Wheaton Academy","Wheaton College","Wheaton Public Library","Winfield Public Library","Winfield School District #34","Wood Dale Public Library District","Wood Dale School District #7");

	var toDoOrNo = "Yes";

	whichOne = document.applicationForm.affiliationselections.options.selectedIndex;
	document.applicationForm.affiliation.value = document.applicationForm.affiliationselections.options[whichOne].text;

	document.applicationForm.YesOrNo.value = toDoOrNo;

	if ( document.applicationForm.affiliationselections.options[whichOne].text == "A-B" ) {
		document.applicationForm.affiliationselections.length = ABlist.length;
		for ( var x=0; x < ABlist.length; x++) {
			document.applicationForm.affiliationselections.options[x].text = ABlist[x];
		}
		document.applicationForm.arraylength.value = ABlist.length;
		document.applicationForm.affiliationselections.options.selectedIndex = 0;
		toDoOrNo = "No";
	}
	if ( document.applicationForm.affiliationselections.options[whichOne].text == "C-E" ) {
		document.applicationForm.affiliationselections.length = CElist.length;
		for ( var x=0; x < CElist.length; x++) {
			document.applicationForm.affiliationselections.options[x].text = CElist[x];
		}
		document.applicationForm.arraylength.value = CElist.length;
		document.applicationForm.affiliationselections.options.selectedIndex = 0;
		toDoOrNo = "No";
	}
	if ( document.applicationForm.affiliationselections.options[whichOne].text == "F-I" ) {
		document.applicationForm.affiliationselections.length = FIlist.length;
		for ( var x=0; x < FIlist.length; x++) {
			document.applicationForm.affiliationselections.options[x].text = FIlist[x];
		}
		document.applicationForm.arraylength.value = FIlist.length;
		document.applicationForm.affiliationselections.options.selectedIndex = 0;
		toDoOrNo = "No";
	}
	if ( document.applicationForm.affiliationselections.options[whichOne].text == "J-M" ) {
		document.applicationForm.affiliationselections.length = JMlist.length;
		for ( var x=0; x < JMlist.length; x++) {
			document.applicationForm.affiliationselections.options[x].text = JMlist[x];
		}
		document.applicationForm.arraylength.value = JMlist.length;
		document.applicationForm.affiliationselections.options.selectedIndex = 0;
		toDoOrNo = "No";
	}
	if ( document.applicationForm.affiliationselections.options[whichOne].text == "N-Q" ) {
		document.applicationForm.affiliationselections.length = NQlist.length;
		for ( var x=0; x < NQlist.length; x++) {
			document.applicationForm.affiliationselections.options[x].text = NQlist[x];
		}
		document.applicationForm.arraylength.value = NQlist.length;
		document.applicationForm.affiliationselections.options.selectedIndex = 0;
		toDoOrNo = "No";
	}
	if ( document.applicationForm.affiliationselections.options[whichOne].text == "R-S" ) {
		document.applicationForm.affiliationselections.length = RSlist.length;
		for ( var x=0; x < RSlist.length; x++) {
			document.applicationForm.affiliationselections.options[x].text = RSlist[x];
		}
		document.applicationForm.arraylength.value = RSlist.length;
		document.applicationForm.affiliationselections.options.selectedIndex = 0;
		toDoOrNo = "No";
	}
	if ( document.applicationForm.affiliationselections.options[whichOne].text == "T-W" ) {
		document.applicationForm.affiliationselections.length = TWlist.length;
		for ( var x=0; x < TWlist.length; x++) {
			document.applicationForm.affiliationselections.options[x].text = TWlist[x];
		}
		document.applicationForm.arraylength.value = TWlist.length;
		document.applicationForm.affiliationselections.options.selectedIndex = 0;
		toDoOrNo = "No";
	}

	if ( toDoOrNo == "Yes" && document.applicationForm.affiliationselections.options[whichOne].text == "-- Back to range selections --" ) {
		document.applicationForm.affiliationselections.length = 8;
		document.applicationForm.affiliationselections.options[0].text = "-- Select a range of the alphabet --";
		document.applicationForm.affiliationselections.options[1].text = "A-B";
		document.applicationForm.affiliationselections.options[2].text = "C-E";
		document.applicationForm.affiliationselections.options[3].text = "F-I";
		document.applicationForm.affiliationselections.options[4].text = "J-M";
		document.applicationForm.affiliationselections.options[5].text = "N-Q";
		document.applicationForm.affiliationselections.options[6].text = "R-S";
		document.applicationForm.affiliationselections.options[7].text = "T-W";
		document.applicationForm.affiliationselections.options.selectedIndex = 0;
		document.applicationForm.arraylength.value = document.applicationForm.affiliationselections.length;
	}

	if ( document.applicationForm.affiliation.value == "-- Back to range selections --" || document.applicationForm.affiliation.value == "-- Select your Affiliation --" ||  document.applicationForm.affiliation.value == "------------" ) {
		toDoOrNo = "No";
	}

	if ( document.applicationForm.affiliation.value == "------------" || document.applicationForm.affiliation.value == "-- Back to range selections --" ) {
		document.applicationForm.affiliationselections.options.selectedIndex = 0;
		document.applicationForm.affiliation.value = "";
		toDoOrNo = "No";
	}
if ( document.applicationForm.affiliation.value == "A-B" ) {
		document.applicationForm.affiliation.value = "";
}
if ( document.applicationForm.affiliation.value == "C-E" ) {
		document.applicationForm.affiliation.value = "";
}
if ( document.applicationForm.affiliation.value == "F-I" ) {
		document.applicationForm.affiliation.value = "";
}
if ( document.applicationForm.affiliation.value == "J-M" ) {
		document.applicationForm.affiliation.value = "";
}
if ( document.applicationForm.affiliation.value == "N-Q" ) {
		document.applicationForm.affiliation.value = "";
}
if ( document.applicationForm.affiliation.value == "R-S" ) {
		document.applicationForm.affiliation.value = "";
}
if ( document.applicationForm.affiliation.value == "T-W" ) {
		document.applicationForm.affiliation.value = "";
}

	if ( document.applicationForm.affiliation.value != "-- Back to range selections --" && document.applicationForm.affiliation.value != "-- Select your Affiliation --" &&  document.applicationForm.affiliation.value != "------------" ) {
		
	}
//	Next line will not be needed when completed...along with any code that sets the object value
	document.applicationForm.YesOrNo.value = toDoOrNo;

}

function checkRequired() {
	goodToGo = 'yes';
	if ( document.applicationForm.applicantFirstName.value == "" && goodToGo == 'yes' ) {
		goodToGo = 'no';
		document.applicationForm.applicantFirstName.focus();
		alert('This form may not be submitted without the applicant\'s first name.');
	}
	if ( document.applicationForm.applicantLastName.value == "" && goodToGo == 'yes' ) {
		goodToGo = 'no';
		document.applicationForm.applicantLastName.focus();
		alert('This form may not be submitted without the applicant\'s last name.');
	}
	if ( document.applicationForm.applicantAddress.value == "" && goodToGo == 'yes' ) {
		goodToGo = 'no';
		document.applicationForm.applicantAddress.focus();
		alert('This form may not be submitted without the applicant\'s street address.');
	}
	if ( document.applicationForm.applicantCity.value == "" && goodToGo == 'yes' ) {
		goodToGo = 'no';
		document.applicationForm.applicantCity.focus();
		alert('This form may not be submitted without the applicant\'s city.');
	}
	if ( document.applicationForm.applicantState.value == "" && goodToGo == 'yes' ) {
		goodToGo = 'no';
		document.applicationForm.applicantState.focus();
		alert('This form may not be submitted without the applicant\'s state.');
	}
	if ( document.applicationForm.applicantZip.value == "" && goodToGo == 'yes' ) {
		goodToGo = 'no';
		document.applicationForm.applicantZip.focus();
		alert('This form may not be submitted without the applicant\'s ZIP code.');
	}
	if ( document.applicationForm.applicantWorkPhone.value == "" && goodToGo == 'yes' ) {
		goodToGo = 'no';
		document.applicationForm.applicantWorkPhone.focus();
		alert('This form may not be submitted without the applicant\'s work phone.');
	}
	// A hidden text field holds the real value, the check is done on that and the focus is to the drop-down list.
	if ( document.applicationForm.affiliation.value == "" && goodToGo == 'yes' ) {
		goodToGo = 'no';
		document.applicationForm.affiliationselections.focus();
		alert('Applicants must work for a DLS member library or parent organization. Please select the affiliation and resubmit the form.');
	}
	if ( document.applicationForm.applicantCurrentSchool.value == "" && goodToGo == 'yes' ) {
		goodToGo = 'no';
		document.applicationForm.applicantCurrentSchool.focus();
		alert('Applicants must be currently enrolled in a library science program or show intent to enroll. Please specify the school and resubmit the form.');
	}
	// This one needs more parameter checking to handle the two check boxes.
	if ( document.applicationForm.applicantEnrolledIn[0].checked == false && document.applicationForm.applicantEnrolledIn[1].checked == false && goodToGo == 'yes' ) {
		goodToGo = 'no';
		document.applicationForm.applicantEnrolledIn[0].focus();
		alert('Indicate Master of Library Science or LTA program and resubmit the form.');
	}
	if ( document.applicationForm.applicantEssay.value == "" && goodToGo == 'yes' ) {
		goodToGo = 'no';
		document.applicationForm.applicantEssay.focus();
		alert('This form may not be submitted without an essay.');
	}
	if ( document.applicationForm.referenceFirstName.value == "" && goodToGo == 'yes' ) {
		goodToGo = 'no';
		document.applicationForm.referenceFirstName.focus();
		alert('This form may not be submitted without the name of your professional reference.');
	}
	if ( document.applicationForm.referenceLastName.value == "" && goodToGo == 'yes' ) {
		goodToGo = 'no';
		document.applicationForm.referenceLastName.focus();
		alert('This form may not be submitted without the name of your professional reference.');
	}
	if ( document.applicationForm.referenceAddress.value == "" && goodToGo == 'yes' ) {
		goodToGo = 'no';
		document.applicationForm.referenceAddress.focus();
		alert('This form may not be submitted without the street address of your professional reference.');
	}
	if ( document.applicationForm.referenceCity.value == "" && goodToGo == 'yes' ) {
		goodToGo = 'no';
		document.applicationForm.referenceCity.focus();
		alert('This form may not be submitted without the city of your professional reference’s address.');
	}
	if ( document.applicationForm.referenceState.value == "" && goodToGo == 'yes' ) {
		goodToGo = 'no';
		document.applicationForm.referenceState.focus();
		alert('This form may not be submitted without the state of your professional reference’s address.');
	}
	if ( document.applicationForm.referenceZip.value == "" && goodToGo == 'yes' ) {
		goodToGo = 'no';
		document.applicationForm.referenceZip.focus();
		alert('This form may not be submitted without the ZIP code of your professional reference.');
	}

	if ( goodToGo == 'yes' ) {
		document.applicationForm.submit();
	}

}

function emailCheck(emailToCheck) {
	var emailStr = emailToCheck.value;
	if (emailStr != "" ) {
		var checkTLD=1;
		var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
		var emailPat=/^(.+)@(.+)$/;
		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
		var validChars="\[^\\s" + specialChars + "\]";
		var quotedUser="(\"[^\"]*\")";
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		var atom=validChars + '+';
		var word="(" + atom + "|" + quotedUser + ")";
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
		var matchArray=emailStr.match(emailPat);   
		if (matchArray==null) {
			alert("Email address seems incorrect (check @ and .'s)\nIf you wish to fix this later, remove the entire email address for now to avoid this error message.  You may also submit this form without an email address.");
			emailToCheck.focus();
			return false;
		}
		var user=matchArray[1];
		var domain=matchArray[2];
		for (i=0; i<user.length; i++) {
			if (user.charCodeAt(i)>127) {
				alert("Ths email address contains invalid characters.\nIf you wish to fix this later, remove the entire email address for now to avoid this error message.  You may also submit this form without an email address.");
				emailToCheck.focus();
				return false;
			}
		}
		for (i=0; i<domain.length; i++) {
			if (domain.charCodeAt(i)>127) {
				alert("Ths domain name contains invalid characters.\nIf you wish to fix this later, remove the entire email address for now to avoid this error message.  You may also submit this form without an email address.");
				emailToCheck.focus();
				return false;
			}
		}
		if (user.match(userPat)==null) {
			alert("The email address doesn't seem to be valid.\nIf you wish to fix this later, remove the entire email address for now to avoid this error message.  You may also submit this form without an email address.");
			emailToCheck.focus();
			return false;
		}
		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null) {
			for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
						alert("Destination IP address is invalid!\nIf you wish to fix this later, remove the entire email address for now to avoid this error message.  You may also submit this form without an email address.");
					emailToCheck.focus();
					return false;
				}	
			}	
			return true;
		}
		var atomPat=new RegExp("^" + atom + "$");
		var domArr=domain.split(".");
		var len=domArr.length;
		for (i=0;i<len;i++) {
			if (domArr[i].search(atomPat)==-1) {
				alert("The domain name does not seem to be valid.\nIf you wish to fix this later, remove the entire email address for now to avoid this error message.  You may also submit this form without an email address.");
				emailToCheck.focus();
				return false;
			}
		}
		if (checkTLD && domArr[domArr.length-1].length!=2 && 
			domArr[domArr.length-1].search(knownDomsPat)==-1) {
			alert("The address must end in a well-known domain or two letter " + "country.\nIf you wish to fix this later, remove the entire email address for now to avoid this error message.  You may also submit this form without an email address.");
			emailToCheck.focus();
			return false;
		}
		if (len<2) {
			alert("This address is missing a hostname!\nIf you wish to fix this later, remove the entire email address for now to avoid this error message.  You may also submit this form without an email address.");
			emailToCheck.focus();
			return false;
		}
		return true;
	}
}

function validateAppFirstName() {
	var firstNameString = new String(document.applicationForm.applicantFirstName.value);
	var fNameFirstChar = firstNameString.substring(0, 1);
	var newFNameFirstChar = fNameFirstChar.toUpperCase();
	if ( fNameFirstChar != newFNameFirstChar ) {
		document.applicationForm.applicantFirstName.value = newFNameFirstChar + firstNameString.substring(1);
		alert("Your entry for first name was changed!!\n\nFrom:\n" + fNameFirstChar + firstNameString.substring(1) + "\n\nTo:\n" + newFNameFirstChar + firstNameString.substring(1) + "\n\nPlease check the entry for correctness.");
		document.applicationForm.applicantFirstName.focus();
	}
}

function validateRefFirstName() {
	var firstNameString = new String(document.applicationForm.referenceFirstName.value);
	var fNameFirstChar = firstNameString.substring(0, 1);
	var newFNameFirstChar = fNameFirstChar.toUpperCase();
	if ( fNameFirstChar != newFNameFirstChar ) {
		document.applicationForm.referenceFirstName.value = newFNameFirstChar + firstNameString.substring(1);
		alert("Your entry for first name was changed!!\n\nFrom:\n" + fNameFirstChar + firstNameString.substring(1) + "\n\nTo:\n" + newFNameFirstChar + firstNameString.substring(1) + "\n\nPlease check the entry for correctness.");
		document.applicationForm.referenceFirstName.focus();
	}
}

function validateAppLastName() {
	var lastNameString = new String(document.applicationForm.applicantLastName.value);
	var lNameFirstChar = lastNameString.substring(0, 1);
	var newLNameFirstChar = lNameFirstChar.toUpperCase();
	if ( lNameFirstChar != newLNameFirstChar ) {
		document.applicationForm.applicantLastName.value = newLNameFirstChar + lastNameString.substring(1);
		alert("Your entry for last name was changed!!\n\nFrom:\n" + lNameFirstChar + lastNameString.substring(1) + "\n\nTo:\n" + newLNameFirstChar + lastNameString.substring(1) + "\n\nPlease check the entry for correctness.");
		document.applicationForm.applicantLastName.focus();
	}
}

function validateRefLastName() {
	var lastNameString = new String(document.applicationForm.referenceLastName.value);
	var lNameFirstChar = lastNameString.substring(0, 1);
	var newLNameFirstChar = lNameFirstChar.toUpperCase();
	if ( lNameFirstChar != newLNameFirstChar ) {
		document.applicationForm.referenceLastName.value = newLNameFirstChar + lastNameString.substring(1);
		alert("Your entry for last name was changed!!\n\nFrom:\n" + lNameFirstChar + lastNameString.substring(1) + "\n\nTo:\n" + newLNameFirstChar + lastNameString.substring(1) + "\n\nPlease check the entry for correctness.");
		document.applicationForm.referenceLastName.focus();
	}
}

function stateCheck(checkThisState) {
	stateString = checkThisState.value;
	if ( stateString != "" ) {
		stateString = stateString.toUpperCase();
		if ( stateString.length == 2 ) {
			checkThisState.value = stateString;
		}
		if ( stateString.length != 2 ) {
			checkThisState.focus();
			alert("State codes must be two letters only.");
		}
	}
}

function provideAreaCode(phoneField) {
	if ( phoneField.value == "" ) {
		phoneField.value = "630-";
	}
}

function CountWords(this_field) {
	var char_count = this_field.value.length;
	if ( char_count != 0 ) {
		var fullStr = this_field.value + " ";
		var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
		var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
		var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
		var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
		var splitString = cleanedStr.split(" ");
		var word_count = splitString.length -1;
		if ( word_count > 500 ) {
			alert("Please limit your essay to 500 words.  This form may not be submitted with an essay longer than 500 words.");
			this_field.focus();
			checkLastCharCode = 0;
			while ( word_count > 500 ) {

				charsNow = this_field.value.length - 1;
				aNewEssayString = this_field.value.substring(0, charsNow);
				this_field.value = aNewEssayString;
				charsNow = this_field.value.length - 1;
				checkLastChar = this_field.value.substring(charsNow - 1, 1);
				checkLastCharCode = this_field.value.charCodeAt(charsNow);
				hackAtIt = "yes";
				while ( hackAtIt == "yes" ) {
					if ( checkLastCharCode == 10 ) {
						aNewEssayString = this_field.value.substring(0, charsNow - 2);
						this_field.value = aNewEssayString;
						hackAtIt = "no";
					}  else {
						hackAtIt = 'no';
					}
					// End of if checklastchar
					charsNow = this_field.value.length - 1;
				}  // End of While hackAtIt
				fullStr = this_field.value;// + " ";
				initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
				left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
				non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
				cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
				splitString = cleanedStr.split(" ");
				word_count = splitString.length;// - 1;
			} // End of while word count
		}  // end of if word count
		if (fullStr.length <2) { 
			word_count = 0; 
		} 
		if (word_count == 1) { 
			wordOrWords = " word"; 
		} else { 
			wordOrWords = " words"; 
		} 
		if (char_count == 1) { 
			charOrChars = " character"; 
		} else { 
			charOrChars = " characters"; 
		} 
		document.applicationForm.numWords.value = word_count; 
	} else { 
		document.applicationForm.numWords.value = 0; 
	} 
} 


function checkThePhones(somePhoneToCheck) {
	stringChecker = somePhoneToCheck.value;
	if ( stringChecker == "630-" ) {
		somePhoneToCheck.value = "";
		stringChecker = "";
	}
	if ( stringChecker != "" ) {
		if ( stringChecker.length != 12 ) {
			goodToGo = 'no';
			somePhoneToCheck.focus();
			alert('Phone numbers must be in the format of ###-###-####.  Please correct the phone number.');
		}
	}
}

function checkZIP(aNewZIP) {
	var stringZIP = new String(aNewZIP.value);
	if ( stringZIP.length != 5 && stringZIP.length != 0 ) {
		aNewZIP.focus();
		alert("The ZIP code should only have 5 digits.\nIf you see this message and there appears to be only 5 numbers in the ZIP code, please ensure there are no spaces before or after the ZIP code.");
	}
}

//-->
</script>
</head>

<body bgcolor="#00785F" onload="setupLists();document.applicationForm.applicantFirstName.focus();">
<table width="600" border="1" align="center" cellpadding="7" cellspacing="5" bordercolor="#CCCCCC" bgcolor="#ffffff">
<tr><td>
<table border="0" cellpadding="4" cellspacing="0" width="100%" summary="text">
<tr>
<td width="163" valign="top"><a href="[URL unfurl="true"]http://www.dupagels.lib.il.us"[/URL] target="_top"><img
          src="[URL unfurl="true"]http://www.dupagels.lib.il.us/images/DLS-Anim-Logo.gif"[/URL] align="middle"
          border="0" width="41" height="60" alt="Dupage Library System Website" /> </a></td>
<td width="1027" align="left" valign="middle">
<hr size="1" noshade>
<em><font size="6"><b>DLS Scholarship Application Form</b></font></em>
<hr size="1" noshade></td>
</tr>
<tr>
<td colspan="2" align="center" valign="top"><strong><font size="2">Internet Explorer (Windows) or Safari (Mac) are recommended for this online application.</font>

    <!--
<table>
<tr>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
</tr>
</table>
-->
</strong></td>
</tr>
</table>
<!-- <form name="applicationForm"> -->
<form  name="applicationForm" method="post" action="/cgi-bin/scholarship/scholarship.cgi">
<table border="0">
<tr>
<td align="right"><b>First Name:</b></td>
<td valign="top">
<input name="applicantFirstName" type="text" id="applicantFirstName" size="70" onblur="validateAppFirstName();">
</td>
</tr>
<tr>
<td align="right"><b>Last Name:</b></td>
<td valign="top"><input name="applicantLastName" type="text" id="applicantLastName" size="70" onblur="validateAppLastName();"></td>
</tr>
<tr>
<td align="right"><b>Street Address:</b></td>
<td valign="top">
<input name="applicantAddress" type="text" size="70">
</td>
</tr>
<tr>
<td align="right"><b>City:</b></td>
<td valign="top">
<input name="applicantCity" type="text" size="70">
</td>
</tr>
<tr>
<td align="right"><strong>State:</strong></td>
<td valign="top">
<input name="applicantState" type="text" size="5" onblur="stateCheck(document.applicationForm.applicantState);">
</td>
</tr>
<tr>
<td align="right"><strong>ZIP:</strong></td>
<td valign="top">
<input name="applicantZip" type="text" size="10" onblur="checkZIP(document.applicationForm.applicantZip);">
</td>
</tr>
<tr>
<td align="right"><b>Work Phone:</b></td>
<td valign="top">
<input name="applicantWorkPhone" type="text"size="20" onfocus="provideAreaCode(document.applicationForm.applicantWorkPhone);" onblur="checkThePhones(document.applicationForm.applicantWorkPhone);">
<font size="2">(With area code)</font></td>
</tr>
<tr>
<td align="right"><b>Home Phone:</b></td>
<td valign="top">
<input name="applicantHomePhone" type="text" size="20" onfocus="provideAreaCode(document.applicationForm.applicantHomePhone);" onblur="checkThePhones(document.applicationForm.applicantHomePhone);">
<font size="2">(With area code) (optional)</font></td>
</tr>
<tr>
<td align="right" valign="top"><b> Email:</b></td>
<td valign="top"><p><b>
<input name="applicantEmail" type="text" size="70" onblur="emailCheck(document.applicationForm.applicantEmail);">
<br>
</b><table>
<tr><td valign="top"><input type="checkbox" name="applicantEmailChoice" value="email2applicant"></td><td><font size="2">Check this checkbox if you provided your email address and wish to have a copy of this application emailed to you.</font></td>
</tr></table></td>
</tr>
</table>
<table>
<tr>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
</tr>
</table>
<p><b>In which DLS library or member organization are you employed or serve as a trustee?<br>
<select name="affiliationselections" size="1" onchange="selectingList();">
<option>Please make a selection.</option>
</select>
<input type="hidden" name="affiliation" size="50" value="">
<input type="hidden" name="YesOrNo" size="20">
<input type="hidden" name="arraylength" size="20">
</b></p>
<table>
<tr>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
</tr>
</table>
<p><strong>Where are you currently taking classes, have been accepted, or intend to enroll?</strong><br>
(If not currently enrolled or accepted, send a letter or registration form to show intent to enroll. Send to DuPage Library System, Scholarship Committee, 127 S. First Street, Geneva, IL 60134-2771.)<b><br>
<input name="applicantCurrentSchool" type="text" size="70">
</b></p>
<table>
<tr>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
</tr>
</table>
<p><b>Please indicate the program you are enrolled in or intend to enroll in:</b></p>
<p><b>
<input name="applicantEnrolledIn" type="checkbox" value="Master of Library Scienc" onclick='javascript:document.applicationForm.applicantEnrolledIn[1].checked=false;'>
Master of Library Science<br>
<input name="applicantEnrolledIn" type="checkbox" value="LTA (Library Technical Assistant)" onclick='javascript:document.applicationForm.applicantEnrolledIn[0].checked=false;'>
LTA (Library Technical Assistant)</b></p>
<table>
<tr>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
</tr>
</table>
<p><b>ESSAY QUESTION</b></p>
<p>State briefly why you would like to be a librarian or library technical assistant and what particular aspects of the profession interest you most. (Maximum of 500 words)</p>
<textarea name="applicantEssay" cols="90" rows="24" wrap="hard" onkeyup="CountWords(document.applicationForm.applicantEssay);" onfocus="wordCounterDIV.style.visibility='visible'" onblur="wordCounterDIV.style.visibility='hidden'">
</textarea>
<div id="wordCounterDIV" style="visibility:hidden; position:relative; left:0; top:0;">Current word count:
<input type="text" name="numWords" id="numWords" size="10">
</div>
<table>
<tr>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
<td width="30"><hr width="20" size="1" noshade></td>
</tr>
</table>

<table width="100%" border="0">
<tr>
<th align="left" bgcolor="#E0E0E0" scope="row"> <p><b>REFERENCE</b></p>
<p>Complete the following information for the person who will send your professional reference:</p>
<table border="0">
<tr>
<td align="right"><b>First Name:</b></td>
<td>
<input name="referenceFirstName" type="text" id="referenceFirstName" size="70" onblur="validateRefFirstName();">
</td>
</tr>
<tr>
<td align="right"><b>Last Name:</b></td>
<td>
<input name="referenceLastName" type="text" id="referenceLastName" size="70" onblur="validateRefLastName();">
</td>
</tr>
<tr>
<td align="right"><b>Street Address:</b></td>
<td>
<input name="referenceAddress" type="text" size="70">
</td>
</tr>
<tr>
<td align="right"><b>City:</b></td>
<td>
<input name="referenceCity" type="text" size="70">
</td>
</tr>
<tr>
<td align="right"><strong>State:</strong></td>
<td>
<input name="referenceState" type="text" size="5" onblur="stateCheck(document.applicationForm.referenceState);">
</td>
</tr>
<tr>
<td align="right"><strong>Zip:</strong></td>
<td>
<input name="referenceZip" type="text" size="10" onblur="checkZIP(document.applicationForm.referenceZip);">
</td>
</tr>
<tr>
<td align="right"><b>Work Phone:</b></td>
<td>
<input name="referenceWorkPhone" type="text"size="20" onfocus="provideAreaCode(document.applicationForm.referenceWorkPhone);" onblur="checkThePhones(document.applicationForm.referenceWorkPhone);">
</td>
</tr>
<tr>
<td align="right"><b>Home Phone:</b></td>
<td>
<input name="referenceHomePhone" type="text" size="20" onfocus="provideAreaCode(document.applicationForm.referenceHomePhone);" onblur="checkThePhones(document.applicationForm.referenceHomePhone);">
<font size="2">(optional)</font></td>
</tr>
<tr>
<td align="right" valign="top"><b>Email:</b></td>
<td><p>
<input name="referenceEmail" type="text" size="70" onblur="emailCheck(document.applicationForm.referenceEmail);">
<br>
<table>
<tr><td valign="top"><input type="checkbox" name="referentEmailChoice" value="email2referent"></td>
<td><font size="2">Check this box to email the information below to the reference's email address.<br>
If you provided an email address for yourself, a copy will be sent to you also.</font></td>
</tr></table>
</td>
</tr>
</table>
<p>Your reference must address the following questions in no more than one double-spaced page:</p>
<ol>
<li>How long have you known this person?</li>
<li>Please address this person&rsquo;s leadership qualities and potential to make an impact on the field. Give specific examples.</li>
<li>What personal qualities make this person a good candidate?</li>
</ol>
<p>Mail the letter of professional recommendation to:</p>
<blockquote>
<p>DuPage Library System<br>
Scholarship Committee<br>
127 S. First Street<br>
Geneva, IL 60134-2771</p>
</blockquote></th>
</tr>
</table>
<hr size="1" noshade />
<p><font size="2">If you wish to print this application, please do so before submitting it. (You may also want to review your page setup before printing.)<br><br>
Upon submission, a copy of the application will be sent to the applicant's email address if one was provided.</font></p>
<p>
<input type="button" name="Submit" value="Submit" onclick="checkRequired();">
</p>
</form>

<hr size="1" noshade />
<p align="center">
<a href="[URL unfurl="true"]http://www.dupagels.lib.il.us/index.html"[/URL] target="_top"><img src="[URL unfurl="true"]http://www.dupagels.lib.il.us/images/footer.gif"[/URL] alt="footer.gif - 2.1 K" border="0" width="246" height="40"></a>
</p>
</td></tr></table>
</body>
</html>
 
i took most of your code (since it was cut off) and applied the exact changes I suggested. it worked perfectly.

here is my function:

Code:
function stateCheck(checkThisState) {
    stateString = checkThisState.value;
    if ( stateString != "" ) {
        stateString = stateString.toUpperCase();
        if ( stateString.length == 2 ) {
            checkThisState.value = stateString;
        }
        if ( stateString.length != 2 ) {
            alert("State codes must be two letters only.");
            setTimeout( "document.getElementById('" + checkThisState.id + "').focus();", 1 );
        }
    }
}

here is my state input field:

Code:
<input id="corystate" name="applicantState" type="text" size="5" onblur="stateCheck(document.applicationForm.applicantState);">



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
That is odd. For me, the exact code is not putting focus on the zip code field after I click away the alert message.

You are using Firefox...correct?
 
Here is the page that has the most recent changes where the check state function is:

Code:
function stateCheck(checkThisState) {
    stateString = checkThisState.value;
    if ( stateString != "" ) {
        stateString = stateString.toUpperCase();
        if ( stateString.length == 2 ) {
            checkThisState.value = stateString;
        }
        if ( stateString.length != 2 ) {
            alert("State codes must be two letters only.");
            setTimeout( "document.getElementById('" + checkThisState.id + "').focus();", 1 );
        }
    }
}



This is the original page where the alert box just hangs when incorrect data is entered into state, zip, or any phone number.

 
this is the kind of thing that's very frustrating for us. i have suggested, twice, to modify the function and to make sure your state input element has an ID, which it still does not in the URL you have provided.



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Sorry about my confusion. I was modifying multiple versions of the code, trying different things and I made a stupid mistake of using the version where I didn't set the id...thinking that I did.

I appreciate all of your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top