/*********************************************************************Script di controllo dei campi di testo	Versione 1.0	Gruppo Webegg - Webegg S.p.A        Federico Fraticelli*********************************************************************/        /*********************************************************************        Function: replaceString        Purpose:  Replaces "txt" with "by" in "str"        Inputs:   string - source string                  text -        Returns:  newstr (the modified string)	*********************************************************************/function replaceString(str, txt, by) {    var strLength = str.length, txtLength = txt.length;    if ((strLength == 0) || (txtLength == 0)) return str;    var i = str.indexOf(txt);    if ((!i) && (txt != str.substring(0,txtLength))) return str;    if (i == -1) return str;    var newstr = str.substring(0,i) + by;    if (i+txtLength < strLength)        newstr += replaceString(str.substring(i+txtLength,strLength),txt,by);    return newstr;}	/*********************************************************************        Function: replaceString        Purpose:  Extended trim function, replaces any ' ', \r, \n char from "str"        Inputs:   String str (source string)        Returns:  String str (trimmed string)	*********************************************************************/function trimSpace(str){        // first trims " "        str = str.replace(/(^\s*)|(\s*$)/g, "");        // then trims "\n\r"        return replaceString(replaceString(replaceString(str,'\r',''),'\n',' '),'\"','\'');}function trimEx(str){		// then translates doublequotes '"' in space ' '		str = replaceString(str,'\"','');		// then translates singlequotes ''' in 2 singlequote '''' as Oracle likes        return replaceString(str,'\'','\'\'');}	/*********************************************************************	*********************************************************************/function verifyForm(){		//elimino spazi e ritorni a capo nei campi	    document.all.FIRSTNAME.value=trimSpace(document.all.FIRSTNAME.value);    	document.all.LASTNAME.value=trimSpace(document.all.LASTNAME.value);	    document.all.ADDRESS.value=trimSpace(document.all.ADDRESS.value);	    document.all.COMPANY.value=trimSpace(document.all.COMPANY.value);	    document.all.CITY.value=trimSpace(document.all.CITY.value);	    document.all.STATE.value=trimSpace(document.all.STATE.value);	    document.all.ZIP.value=trimSpace(document.all.ZIP.value);	    document.all.COUNTRY.value=trimSpace(document.all.COUNTRY.value);	    document.all.PHONE.value=trimSpace(document.all.PHONE.value);	    document.all.FAX.value=trimSpace(document.all.FAX.value);	    document.all.EMAIL.value=trimSpace(document.all.EMAIL.value);				//verifica l'obbligatorieta' dei campi	    if(document.all.FIRSTNAME.value.length<1){			alert("Please enter your name");			return false;			}			    	if(document.all.LASTNAME.value.length<1){			alert("Please enter your surname");			return false;			}	    if(document.all.EMAIL.value.length<6){			alert("Please enter your e-mail address");			return false;			}	    if ( (document.all.EMAIL.value.indexOf("@") == -1) || (document.all.EMAIL.value.indexOf(".") == -1) ){			alert("Please enter a valid e-mail address");			return false;			}		//verifica la dimensione massima dei campi	    if(document.all.FIRSTNAME.value.length>30){			alert("The name cannot be longer than 30 letters");			return false;			}			    	if(document.all.LASTNAME.value.length>30){			alert("The surname cannot be longer than 30 letters");			return false;			}    	if(document.all.COMPANY.value.length>30){			alert("The company name cannot be longer than 30 letters");			return false;			}	    if(document.all.EMAIL.value.length>80){			alert("The e-mail address cannot be longer than 80 letters");			return false;			}	    if(document.all.PHONE.value.length>15){			alert("The phone number cannot be longer than 15 letters");			return false;			}	    if(document.all.FAX.value.length>15){			alert("The fax number cannot be longer than 15 letters");			return false;			}	    if(document.all.ADDRESS.value.length>30){			alert("The address  cannot be longer than 30 letters");			return false;			}	    if(document.all.CITY.value.length>30){			alert("The city name cannot be longer than 30 letters");			return false;			}	    if(document.all.STATE.value.length>40){			alert("The state name cannot be longer than 40 letters");			return false;			}	    if(document.all.ZIP.value.length>10){			alert("The P.O. box cannot be longer than 10 letters");			return false;			}	    if(document.all.COUNTRY.value.length>40){			alert("The country name cannot be longer than 40 letters");			return false;			}		//trasforma i caratteri indesiderati	    document.all.FIRSTNAME.value=trimEx(document.all.FIRSTNAME.value);    	document.all.LASTNAME.value=trimEx(document.all.LASTNAME.value);    	document.all.COMPANY.value=trimEx(document.all.COMPANY.value);	    document.all.ADDRESS.value=trimEx(document.all.ADDRESS.value);	    document.all.CITY.value=trimEx(document.all.CITY.value);	    document.all.STATE.value=trimEx(document.all.STATE.value);	    document.all.ZIP.value=trimEx(document.all.ZIP.value);	    document.all.COUNTRY.value=trimEx(document.all.COUNTRY.value);	    document.all.PHONE.value=trimEx(document.all.PHONE.value);	    document.all.FAX.value=trimEx(document.all.FAX.value);	    document.all.EMAIL.value=trimEx(document.all.EMAIL.value);				return true;}