function checkItNum(evt) { 
	evt = (evt) ? evt : window.event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if (charCode < 48 || charCode > 57) {
		//alert("This field accepts numbers only."); //You can Comment this line out if you do not want to alert the user.
		status = "This field accepts numbers only."
		return false
	}
	status = ""
	return true
}

function checkItTime(evt) { 
	evt = (evt) ? evt : window.event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if ((charCode < 48 || charCode > 58) && (charCode != 65) && (charCode != 97) && (charCode != 77) && (charCode != 109) && (charCode != 80) && (charCode != 112)){
		//alert("This field accepts numbers only."); //You can Comment this line out if you do not want to alert the user.
		status = "This field accepts time notation characters only."
		return false
	}
	status = ""
	return true
}

function checkItDate(evt) { 
	evt = (evt) ? evt : window.event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if (charCode < 47 || charCode > 57) {
		//alert("This field accepts numbers only."); //You can Comment this line out if you do not want to alert the user.
		status = "This field accepts date notation characters only. (numerals and slash)"
		return false
	}
	status = ""
	return true
}

function checkItMoney(fld,evt) { 
	evt = (evt) ? evt : window.event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if (fld.value.substr(0,1) == '0') fld.value = '';
	if (((charCode < 48 || charCode > 57) && charCode != 46) || (charCode == 46 && fld.value.indexOf('.') != -1) || (fld.value.indexOf('.') != -1 && fld.value.substring(fld.value.indexOf('.'),fld.value.length).length > 2)) {
		//alert("This field accepts numbers only."); //You can Comment this line out if you do not want to alert the user.
		status = "This field accepts numbers and one decimal only."
		return false
	}
	status = ""
	return true
}

function checkItAlpha(evt) { 
	evt = (evt) ? evt : window.event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if ((charCode != 32 && charCode < 65) || (charCode > 122) || (charCode > 90 && charCode < 97)) {
		//alert("This field accepts alpha characters only."); //You can Comment this line out if you do not want to alert the user.
		status = "This field accepts alpha characters only."
		return false
	}
	status = ""
	return true
}

function checkItAlphaNum(evt) { 
	evt = (evt) ? evt : window.event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if ((charCode != 32 && charCode < 48) || (charCode > 57 && charCode < 65) || (charCode > 90 && charCode < 97) || (charCode > 122)) {
		//alert("This field accepts alphanumeric characters only."); //You can Comment this line out if you do not want to alert the user.
		status = "This field accepts alphanumeric characters only."
		return false
	}
	status = ""
	return true
}

function checkItAlphaNumCr(evt) { 
	evt = (evt) ? evt : window.event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if ((charCode != 13 && charCode != 32 && charCode < 48) || (charCode > 57 && charCode < 65) || (charCode > 90 && charCode < 97) || (charCode > 122)) {
		//alert("This field accepts alphanumeric characters and line breaks only."); //You can Comment this line out if you do not want to alert the user.
		status = "This field accepts alphanumeric characters and line breaks only."
		return false
	}
	status = ""
	return true
}

function checkItEmail(evt) { 
	evt = (evt) ? evt : window.event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if ((charCode < 45) || (charCode > 122) || (charCode == 47) || (charCode > 57 && charCode < 64) || (charCode > 64 && charCode < 95) || (charCode > 95 && charCode < 97)){
		//alert("This field accepts email-valid characters only."); //You can Comment this line out if you do not want to alert the user.
		status = "This field accepts email-valid characters only."
		return false
	}
	status = ""
	return true
}

function chkSSN() {
	var f = document.FBDLoanApp.SSN.value;
	if (f.length != 9){
		alert('Please verify your Social Security number. It must be 9 digits in length.');
		return false;
	}
	else return true
}

function chkYears() {
	var f = document.FBDLoanApp;
	var yr = 1850;
	var yrErr = "";
	if (parseInt(f.DateofBirth.value.substring(f.DateofBirth.value.length-4,f.DateofBirth.value.length)) < yr) yrErr += "\n\tDate of Birth"
	if (parseInt(f.DriverLicenseExpDate.value.substring(f.DriverLicenseExpDate.value.length-4,f.DriverLicenseExpDate.value.length)) < yr) yrErr += "\n\tDriver's license expiration date"
	if (parseInt(f.DateStart.value.substring(f.DateStart.value.length-4,f.DateStart.value.length)) < yr) yrErr += "\n\tHire date"
	if (parseInt(f.NextPayDate.value.substring(f.NextPayDate.value.length-4,f.NextPayDate.value.length)) < yr) yrErr += "\n\tNext pay date"
	if (parseInt(f.SecondPayDate.value.substring(f.SecondPayDate.value.length-4,f.SecondPayDate.value.length)) < yr) yrErr += "\n\tSecond pay date"
	if (yrErr.length > 1){
		alert('In each of the 5 date fields, the year may not be earlier than ' + yr + '.\n\nPlease check these fields:' + yrErr);
		return false;
	}else{
		return true;
	}
}

function chkPhones() {
	var f = document.FBDLoanApp;
	var phoneErr= "";
	if (f.HomePhone.value.length != 10) phoneErr += "\tHome phone number\n"
	if (f.OtherPhone.value != "" && f.OtherPhone.value.length != 10) phoneErr += "\tCell phone number\n"
	if (f.WorkPhone.value.length != 10) phoneErr += "\tWork phone number\n"
	if (f.SupvPhone.value != "" && f.SupvPhone.value.length != 10) phoneErr += "\tSupervisor phone number\n"
	if (f.Ref1Phone.value.length != 10) phoneErr += "\tReference #1 phone number\n"
	if (f.Ref2Phone.value.length != 10) phoneErr += "\tReference #2 phone number\n"
	if (phoneErr.length > 1){
		alert('Please check the following for accuracy:\n\n' + phoneErr + '\nPhone numbers must contain 10 digits; an area code and 7-digit number');
		return false
	}
	else return true
}