function checkData(){	var elForm	if(checkData.arguments.length>0)	{			elForm = document.forms[checkData.arguments[0]]		}	else	{		elForm = document.forms[0]	}	var valore_alt=""	for(i=0;i<obbligatoriText.length;i++)	{        		if(elForm.elements[obbligatoriText[i]])		{			if(obbligatoriTextAlt)			{				nome_campo_alt=obbligatoriTextAlt[i]			}			else			{				nome_campo_alt=""			}						//verifico se esiste il campo indicato come alternativo			if(elForm.elements[nome_campo_alt] && nome_campo_alt.length>0)			{								objAlt=elForm.elements[nome_campo_alt]				valore_alt=elForm.elements[nome_campo_alt].value				if(obbligatoriTextAlt)				{					etichetta_alt=obbligatoriNameTextAlt[i]					tipo_alt=obbligatoriTypeTextAlt[i]								}				else				{					etichetta_alt=obbligatoriNameText[i]					tipo_alt=obbligatoriTypeText[i]								}							}			else			{				objAlt=elForm.elements[obbligatoriText[i]]				valore_alt=elForm.elements[obbligatoriText[i]].value				etichetta_alt=obbligatoriNameText[i]				tipo_alt=obbligatoriTypeText[i]			}									if(elForm.elements[obbligatoriText[i]].value == "" && valore_alt=="")			{								if(nome_campo_alt!=="" && nome_campo_alt!=undefined)				{					stringaErrore =	"E' obbligatorio specificare un valore per il campo "+obbligatoriNameText[i]+"\no per il campo  "+obbligatoriNameTextAlt[i]+"!" 				}				else				{					stringaErrore =	"Il campo "+obbligatoriNameText[i]+" è obbligatorio!" 				}				alert(stringaErrore);				elForm.elements[obbligatoriText[i]].focus();				elForm.elements[obbligatoriText[i]].select();				return false;			}							if ((obbligatoriTypeText[i] == "number")  && (!isNumber(elForm.elements[obbligatoriText[i]].value))) 			{				var stringaErrore =	"Il valore di "+obbligatoriNameText[i]+" deve essere numerico!" 				alert(stringaErrore);				elForm.elements[obbligatoriText[i]].focus();				elForm.elements[obbligatoriText[i]].select();				return false;			}			if(valore_alt!="")			{				if ((tipo_alt == "number")  && (!isNumber(valore_alt))) 				{					var stringaErrore =	"Il valore di "+etichetta_alt+" deve essere numerico!" 					alert(stringaErrore);					objAlt.focus();					objAlt.select();					return false;				}			}			if ((obbligatoriTypeText[i] == "numbernegative")  && (!isNumberNegative(elForm.elements[obbligatoriText[i]].value))) 			{				var stringaErrore =	"Il valore di "+obbligatoriNameText[i]+" deve essere numerico!" 				alert(stringaErrore);				elForm.elements[obbligatoriText[i]].focus();				elForm.elements[obbligatoriText[i]].select();				return false;			}			if(valore_alt!="")			{				if ((tipo_alt == "numbernegative")  && (!isNumberNegative(valore_alt))) 				{					var stringaErrore =	"Il valore di "+etichetta_alt+" deve essere numerico!" 					alert(stringaErrore);					objAlt.focus();					objAlt.select();					return false;				}			}						if ((obbligatoriTypeText[i] == "ip")  && (!isValidIP(elForm.elements[obbligatoriText[i]].value))) 			{				var stringaErrore =	"Il valore di "+obbligatoriNameText[i]+" deve essere un indirizzo IP!" 				alert(stringaErrore);				elForm.elements[obbligatoriText[i]].focus();				elForm.elements[obbligatoriText[i]].select();				return false;			}			if(valore_alt!="")			{				if ((tipo_alt == "ip")  && (!isValidIP(valore_alt))) 				{					var stringaErrore =	"Il valore di "+obbligatoriNameText[i]+" deve essere un indirizzo IP!" 					alert(stringaErrore);					elForm.elements[obbligatoriText[i]].focus();					elForm.elements[obbligatoriText[i]].select();					return false;				}			}						if ((obbligatoriTypeText[i] == "pwd")  && (!pwdlen(elForm.elements[obbligatoriText[i]].value))) 			{					var stringaErrore =	"Il valore di "+obbligatoriNameText[i]+" deve contenere almeno 6 caratteri!" 					alert(stringaErrore);						elForm.elements[obbligatoriText[i]].focus();					elForm.elements[obbligatoriText[i]].select();					return false;								}			if(valore_alt!="")			{				if ((tipo_alt == "pwd")  && (!pwdlen(valore_alt))) 				{					var stringaErrore =	"Il valore di "+obbligatoriNameText[i]+"deve contenere almeno 6 caratteri!" 					alert(stringaErrore);					elForm.elements[obbligatoriText[i]].focus();					elForm.elements[obbligatoriText[i]].select();					return false;				}			}							if ((obbligatoriTypeText[i] == "email") && (! isEmail(elForm.elements[obbligatoriText[i]].value))) 			{				elForm.elements[obbligatoriText[i]].focus();				elForm.elements[obbligatoriText[i]].select();				return false;			}			if(valore_alt!="")			{				if ((tipo_alt == "email") && (! isEmail(valore_alt))) 				{					objAlt.focus();					objAlt.select();					return false;				}			}						if ((obbligatoriTypeText[i] == "string") && (! isAlphabetic(elForm.elements[obbligatoriText[i]].value))) 			{				var stringaErrore =	"Il valore di "+obbligatoriNameText[i]+" deve essere alfabetico!" 				alert(stringaErrore);				elForm.elements[obbligatoriText[i]].focus();				elForm.elements[obbligatoriText[i]].select();				return false;			}						if(valore_alt!="")			{				if ((tipo_alt == "string") && (! isAlphabetic(valore_alt))) 				{					var stringaErrore =	"Il valore di "+etichetta_alt+" deve essere alfabetico!" 					alert(stringaErrore);					objAlt.focus();					objAlt.select();					return false;				}			}		}				if ((obbligatoriTypeText[i] == "data") && (!validateDate(elForm.elements[obbligatoriText[i]].value))) 		{ 				var stringaErrore =	"La data indicata in " +obbligatoriNameText[i] + " deve essere di formato valido (dd/mm/yyyy)! \n"+									"Il " + elForm.elements[obbligatoriText[i]].value+ " non esiste."				alert(stringaErrore);				elForm.elements[obbligatoriText[i]].focus();				elForm.elements[obbligatoriText[i]].select();				return false;	 						}						//controllo di tipo data per il campo alternativo, a condizione che ci sia		if(obbligatoriTypeTextAlt && valore_alt!="")		{			if(obbligatoriTypeTextAlt.length>i)			{				if ((obbligatoriTypeTextAlt[i] == "data") && (!validateDate(elForm.elements[obbligatoriNameText[i]].value))) 				{ 						var stringaErrore =	"La data indicata in " +obbligatoriNameText[i] + " deve essere di formato valido (dd/mm/yyyy)! \n"+											"Il " + elForm.elements[obbligatoriNameText[i]].value+ " non esiste."						alert(stringaErrore);						elForm.elements[obbligatoriNameText[i]].focus();						elForm.elements[obbligatoriNameText[i]].select();						return false;	 										}			}		}			}	for(i=0;i<valoriObbligatori.length;i++)	{		if(elForm.elements[valoriObbligatori[i]])		{			if(elForm.elements[valoriObbligatori[i]].value != "")			{										if ((valoriObbligatoriType[i] == "number")  && (!isNumber(elForm.elements[valoriObbligatori[i]].value))) 				{					var stringaErrore =	"Il valore di "+valoriObbligatoriName[i]+" deve essere numerico!" 					alert(stringaErrore);					elForm.elements[valoriObbligatori[i]].focus();					elForm.elements[valoriObbligatori[i]].select();					return false;				}				if ((valoriObbligatoriType[i] == "numbernegative")  && (!isNumberNegative(elForm.elements[valoriObbligatori[i]].value))) 				{					var stringaErrore =	"Il valore di "+valoriObbligatoriName[i]+" deve essere numerico!" 					alert(stringaErrore);					elForm.elements[valoriObbligatori[i]].focus();					elForm.elements[valoriObbligatori[i]].select();					return false;				}								if ((valoriObbligatoriType[i] == "ip")  && (!isValidIP(elForm.elements[valoriObbligatori[i]].value))) 				{					var stringaErrore =	"Il valore di "+valoriObbligatoriName[i]+" deve essere un indirizzo IP!" 					alert(stringaErrore);					elForm.elements[valoriObbligatori[i]].focus();					elForm.elements[valoriObbligatori[i]].select();					return false;				}				if ((valoriObbligatoriType[i] == "pwd")  && (!pwdlen(elForm.elements[valoriObbligatori[i]].value))) 				{					var stringaErrore =	"Il valore di "+valoriObbligatoriName[i]+" deve contenere almeno 6 caratteri!" 					alert(stringaErrore);						elForm.elements[valoriObbligatori[i]].focus();					elForm.elements[valoriObbligatori[i]].select();					return false;				}				if ((valoriObbligatoriType[i] == "email") && (! isEmail(elForm.elements[valoriObbligatori[i]].value))) 				{					elForm.elements[valoriObbligatori[i]].focus();					elForm.elements[valoriObbligatori[i]].select();					return false;				}				if ((valoriObbligatoriType[i] == "string") && (! isAlphabetic(elForm.elements[valoriObbligatori[i]].value))) 				{					var stringaErrore =	"Il valore di "+valoriObbligatoriName[i]+" deve essere alfabetico!" 					alert(stringaErrore);					elForm.elements[valoriObbligatori[i]].focus();					elForm.elements[valoriObbligatori[i]].select();					return false;				}				if ((valoriObbligatoriType[i] == "data") && (!validateDate(elForm.elements[valoriObbligatori[i]].value)))				{ 					var stringaErrore =	"La data indicata in " +valoriObbligatori[i] + " deve essere di formato valido (dd/mm/yyyy)! \n"+										"Il " + elForm.elements[valoriObbligatori[i]].value+ " non esiste."					alert(stringaErrore);					elForm.elements[valoriObbligatori[i]].focus();					elForm.elements[valoriObbligatori[i]].select();					return false;	 									}			}		}	}	for(i=0;i<obbligatoriSelect.length;i++)	{		sel=elForm.elements[obbligatoriSelect[i]]				if(sel && !sel.disabled)		{			if(sel.options)			{				if(sel.selectedIndex==-1)				{					alert("Il valore di "+ obbligatoriNameSelect[i] + " è obbligatorio!!!!")					sel.focus();					return false;				}				else				{					if(sel.options[sel.selectedIndex].value=="") 					{						alert("Il valore di "+ obbligatoriNameSelect[i] + " è obbligatorio!")						sel.focus();						return false;					}				}			}		}	}	//alert("tutto ok")	return true;}function isAlphabetic(string){	if(string == "")	{		return true;	}	for (k=0;k<parseInt(string.length);k++)	{		if ((string.charAt(k) < "9" && string.charAt(k) > "0"))		{			return false;		}	}	return true;}function isNumber(number){	if(number == "")	{		return true;	}	if(number.charAt(0)==".")	{ 		return false;	}	if(number.charAt(0)==",")	{ 		return false;	}	for (s=0;s<parseInt(number.length);s++)	{		if ((number.charAt(s) > "9" || number.charAt(s) < "0") && number.charAt(s)!="." && number.charAt(s)!=",")		{			return false;		}	}	return true;}function isNumberGeneral(number){	if(number == "")	{		return true;	}	if(number.charAt(0)==".")	{ 		return false;	}	if(number.charAt(0)==",")	{ 		return false;	}	for (s=0;s<parseInt(number.length);s++)	{		if ((number.charAt(s) > "9" || number.charAt(s) < "0") && number.charAt(s)!="." && number.charAt(s)!=",")		{			return false;		}	}	return true;}function isNumberNegative(number){	if(number == "")	{		return true;	}	if(number.charAt(0)==".")	{ 		return false;	}	if(number.charAt(0)!="-" && !isNumber(number.charAt(0)))	{ 		return false;	}	for (s=1;s<parseInt(number.length);s++)	{		if ((number.charAt(s) > "9" || number.charAt(s) < "0") &&  number.charAt(s)!="." && number.charAt(s)!=",")		{						return false;		}	}		return true;}function pwdlen(pwd){	if(pwd.length >= 6)	{		return true;	}	else	{		return false;	}}function isEmail(email){		emailValida = false	if(email == "")	{				return false;	}	indexOfAt = email.length + 10;	for (j=0;j<parseInt(email.length) && !emailValida;j++)	{		if (email.charAt(j) == "@")		{			emailValida = true;			indexOfAt = j		}	}		if(emailValida) 	{		indexOfDot = email.lastIndexOf(".")				if(indexOfDot <= (indexOfAt + 1))		{						emailValida = false;		}	}	if(! emailValida)	{				alert("L'indirizzo di email non sembra corretto (controlla @ e .)")	}	return emailValida;}function validateDate(fld) {    var RegExPattern = /^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/;       if ((fld.match(RegExPattern)) && (fld!='')) {        return true;     } else {        return false;    } }function isToBeforeFrom(dateFrom,dateTo){		data2=dateFrom.split("/")				dd=eval(data2[0])		mm=eval(data2[1])-1		yy=eval(data2[2])				data_dal=new Date(yy,mm,dd)				data2=dateTo.split("/")				dd=eval(data2[0])		mm=eval(data2[1])-1		yy=eval(data2[2])				data_al=new Date(yy,mm,dd)					if (data_dal >= data_al ) {			alert("Data Da "+dateFrom+" maggiore o uguale alla data Al "+dateTo )            return false;         }			return true;}function isValidIP(IPvalue) {	errorString = "";	theName = "Indirizzo ip";		var ipPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;	var ipArray = IPvalue.match(ipPattern);		if (IPvalue == "0.0.0.0")	{		errorString = errorString + theName + ': '+IPvalue+' è un indirizzo speciale e non può essere usato per queso campo.';	}	else if (IPvalue == "255.255.255.255")	{		errorString = errorString + theName + ': '+IPvalue+' è un indirizzo speciale e non può essere usato per queso campo.';	}	if (ipArray == null)	{		errorString = errorString + theName + ': '+IPvalue+' non è un indirizzo IP valido.';	}	else 	{		for (k = 0; k < 4; k++) {			thisSegment = ipArray[k];			if (thisSegment > 255) {				errorString = errorString + theName + ': '+IPvalue+' non è un indirizzo IP valido.';				k = 4;			}			if ((i == 0) && (thisSegment > 255)) {				errorString = errorString + theName + ': '+IPvalue+' è un indirizzo speciale e non può essere usato per queso campo.';				k = 4;			}		 }	}	extensionLength = 3;	if (errorString == "")	{		return true;	}	else	{		alert (errorString);		return false;	}}