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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't find the uncaught exception

Status
Not open for further replies.

SysTechGuy

Technical User
May 11, 2007
11
0
0
US
I should apologize first because I am a total noob when it comes to javascript. However, my company is using an online application and there are certain fields where when data is entered in the incorrect format (example: A phone number is not entered in the ###-###-#### format) An exception is thrown and a dialog box pops up indicating the error. What is supposed to happen is that the user clicks on the "Okay" button on this popup and the user can fix the format error. What actually happens is that the popup does not go away, and the user has to shut down the browser. This happens for the fields "Home Number", "Work Number", "State" and "Zip Code".

This phenomenon only happens with FirFox for both Windows and Mac machines, and for IE7 on Mac only.

When I use the Safari browser on the Mac, I need to click the Error box exactly 4 times before I am returned to the application.

I included the code below. Can anyone give me any input on this?

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>
 
Without looking too far into this I'll tell you what I think your problem is.

You are setting focus to these fields BEFORE you popup the alert. On these fields you have an event to be called onfocus. It tries to do 2 things at one time.

To fix this. put the focus on the field AFTER the alert, or remove the onfocus function call on the fields and find a different way to call them.

I'd do the first way.

[monkey][snake] <.
 
I tried your advice and it eliminated the problem of locking out the user, but now with the changes that I made, once a user enters an incorrect format for data, the focus goes to the next field. For instance, if I enter 3 letters for state instead of 2, the exception is thrown and a pop-up appears. I click "Okay" and it disappears and I can get to the application again. However, the focus is on the next field, which is the ZIP code. I am a noob so there is a logic error that I am just not seeing.

Here is the original state check function in the code:

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.");
}
}
}

As you pointed out, the focus was being put on the field before the error. So I changed it to this:

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();
}
}
}

The focus is now being put on the field in question after the alert. However it doesn't work like this once I load the page. I enter incorrect data in the State field, the alert is generated, I click on the alert window and I am returned to the page, but then the focus is on the next field.

It seems if I put it the focus before the alert then there is a lock up. After and there is a possibility of sending incorrectly formatted data.

Do you see my error?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top