//USAepay Javascript form validation and formatting script//Developed by Mind2Web for USAepay//For questions or comments email://support@usaepay.com or//mind2webinfo@yahoo.comfunction validateForm(){    var CCN = trimBetweenSpaces(trimBegEndSpaces(stripOffNonDigit(document.ccform.UMcard.value)));	var expireDate = trimBetweenSpaces(trimBegEndSpaces(stripOffNonDigit(document.ccform.UMexpirM.value + document.ccform.UMexpirY.value)));	var name = document.ccform.UMname.value;	var street = document.ccform.UMstreet.value;	var email = document.ccform.UMcustemail.value;	var zip = trimBetweenSpaces(trimBegEndSpaces(stripOffNonDigit(document.ccform.UMzip.value)));						if (name.length == 0 || !isAlphaSymbols(name, ".,' "))	{	 alert ("Please fill out the name field.");	 document.ccform.UMname.focus == true;	 return false;	}			if (street.length == 0)	{	 alert ("Please fill out the street field.");	 document.ccform.UMstreet.focus == true;	 return false;	}			if (zip.length == 0 || zip.length < 5)	{	 alert ("Please fill out the zip field which should be 5 digits.");	 document.ccform.UMzip.focus == true;	 return false;	}		if (email.length == 0 )	{	 alert ("Please fill out the email field");	 document.ccform.UMcustemail.focus == true;	 return false;	}				if (CCN.length == 0 || expireDate.Length == 0)	{		{		   alert ("Please put in your Credit Card Number.");		   document.ccform.UMcard.focus == true;		   return false;		}	}	else	{	 if (expireDate.length < 4)	 {	  alert ("Please enter the expiration date in the format MM/YY.");		   document.ccform.UMexpirM.focus == true;		   return false;	 }	 document.ccform.UMexpir.value = expireDate;	}				return true;}// Return true if a string is combination of alpha and given symbols.function isAlphaSymbols(objValue, symbols) {	var ch		for (var i=0; i < objValue.length; i++) {		ch = objValue.charAt(i)		if (isAlphaChar(ch) == false) {			if (symbols.indexOf(ch) < 0) 				return false		}	}	return true}// Return true of a character is an alphabet.function isAlphaChar( ch ) {   	return ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z"))}// Stiff off any non digit charfunction stripOffNonDigit(objValue) {	var ch	var tempStr = new String()	for (var i=0; i<objValue.length; i++)    {    	if (isDigitChar(objValue.charAt(i)) == true)    	    tempStr = tempStr + objValue.charAt(i)    }		return tempStr}// Return true if a character is a digit.function isDigitChar( ch ) {	return ( ch >= "0" && ch <= "9" )}// Removes leading and trailing blanks from a valuefunction trimBegEndSpaces(object_value){    var leading_blanks = 0    var string_end = (object_value.length)-1    if (string_end < 0) string_end = 0	// find first nonblank:  start with first character and scan forwards    while (leading_blanks <= string_end && object_value.charAt(leading_blanks) == " ")	{leading_blanks++}	// find last nonblank:  start with last character and scan backwards    while (string_end > leading_blanks && object_value.charAt(string_end) == " ")        {string_end--}	return object_value = object_value.substring(leading_blanks,string_end+1)}// Remove any additional spacesfunction trimBetweenSpaces(objValue) {	var blankExists = false	var newValue = new String()	var ch		for (var i=0; i < objValue.length; i++) {		ch = objValue.charAt(i)		if ( ch == " " ) {			if ( blankExists == false ) {				blankExists = true				newValue = newValue + ch							}				}		else {			newValue = newValue + ch			blankExists = false		}	}	if ( newValue == null )		return objValue	else		return newValue}