function CheckModificaDatiUtente(form_name){

	theForm = document.forms[form_name];
	
	//SOLO PER BENFICIARI
	if (document.getElementById('LuogoDiConsegna')) {
	
		if (theForm.idEnteTipologia.value == "")  {
			alert ("Selezionare la tipologia dell'Organizzazione!")
			theForm.idEnteTipologia.focus()
			return false;
		}
				
		if (theForm.CF.value == "")  {
			alert ("Codice fiscale obbligatorio!")
			theForm.CF.focus()
			theForm.CF.select()
			return false;
		} else {
			var erroreCF = ''
			if( theForm.CF.value.length == 16 ) {
				var erroreCF = ControllaCF(theForm.CF.value);
			} else if( theForm.CF.value.length == 11 ) {
				var erroreCF = ControllaPIVA(theForm.CF.value);
			} else {
				//var erroreCF = "Il codice fiscale introdotto non e' valido" 
			}
			
			if (erroreCF != "")  {
				alert (erroreCF)
				theForm.CF.focus()
				theForm.CF.select()
				return false;
			}		
		}	
	
		if (document.getElementById('VerificaCF').innerHTML != "")  {
			alert ("Da un controllo sul codice fiscale l'organizzazione risulta gia' registrata sul portale")
			return false;
		}
	}	
	
	
	/* DATI DELL'ORGANIZZAZIONE */
	//sede legale	
	if (theForm.Indirizzo.value == "")  {
		alert ("Indirizzo della sede legale obbligatorio!")
		theForm.Indirizzo.focus()
		theForm.Indirizzo.select()
		return false;
	}
	
	if (theForm.Citta.value == "")  {
		alert ("Citta' della sede legale obbligatoria!")
		theForm.Citta.focus()
		theForm.Citta.select()
		return false;
	}
	
	if (theForm.idProvincia.value == "")  {
		alert ("Selezionare la provincia della sede legale!")
		theForm.idProvincia.focus()
		return false;
	}			
	
	if (theForm.CAP.value == "")  {
		alert ("CAP della sede legale obbligatorio!")
		theForm.CAP.focus()
		theForm.CAP.select()
		return false;
	}
	
	//sede operativa	
	if (theForm.SedeOperativaIndirizzo.value == "")  {
		alert ("Indirizzo della sede operativa obbligatorio!")
		theForm.SedeOperativaIndirizzo.focus()
		theForm.SedeOperativaIndirizzo.select()
		return false;
	}
	
	if (theForm.SedeOperativaCitta.value == "")  {
		alert ("Citta' della sede operativa obbligatoria!")
		theForm.SedeOperativaCitta.focus()
		theForm.SedeOperativaCitta.select()
		return false;
	}
	
	if (theForm.SedeOperativaidProvincia.value == "")  {
		alert ("Selezionare la provincia della sede operativa!")
		theForm.SedeOperativaidProvincia.focus()
		return false;
	}			
	
	if (theForm.SedeOperativaCAP.value == "")  {
		alert ("CAP della sede operativa obbligatorio!")
		theForm.SedeOperativaCAP.focus()
		theForm.SedeOperativaCAP.select()
		return false;
	}	
	
	if (theForm.Telefono.value == "")  {
		alert ("Telefono obbligatorio!")
		theForm.Telefono.focus()
		theForm.Telefono.select()
		return false;
	}										
	
	/* INFORMAZIONE UTENTE */
	if (theForm.Password.value == "")  {
		alert ("Inserire una Password!")
		theForm.Password.focus()
		theForm.Password.select()
		return false;
	}

	if (theForm.Password.value.length<6)  {
		alert ("La password deve essere composta da almeno 6 caratteri!")
		theForm.Password.focus()
		theForm.Password.select()
		return false;
	}
	
	var illegalChars = /[\W_]/; // allow only letters and numbers	
	
	if (illegalChars.test(theForm.Password.value)==true)  {
		alert ("Solo lettere e numeri ammessi nella password!")
		theForm.Password.focus()
		theForm.Password.select()
		return false;
	}
		
	if (theForm.Password.value!=theForm.Password2.value) {
		alert ("La password inserita nel campo di conferma non coincide con la prima password inserita!")
		theForm.Password.focus()
		theForm.Password.select()
		return false;
	}	
	
	/* CONTATTO DI RIFERIMENTO DELL'ORGANIZZAZIONE */
	if (theForm.NomeReferente.value == "")  {
		alert ("Nome del referente obbligatorio!")
		theForm.NomeReferente.focus()
		theForm.NomeReferente.select()
		return false;
	}	
	
	if (theForm.CognomeReferente.value == "")  {
		alert ("Cognome del referente obbligatorio!")
		theForm.CognomeReferente.focus()
		theForm.CognomeReferente.select()
		return false;
	}
	
	if (theForm.MansioneReferente.value == "")  {
		alert ("Mansione del referente obbligatoria!")
		theForm.MansioneReferente.focus()
		theForm.MansioneReferente.select()
		return false;
	}
	
	if (theForm.TelefonoReferente.value == "")  {
		alert ("Telefono del referente obbligatorio!")
		theForm.TelefonoReferente.focus()
		theForm.TelefonoReferente.select()
		return false;
	}			
	
	if (theForm.EmailReferente.value == "")  {
		alert ("Indirizzo e-mail del referente obbligatorio!")
		theForm.EmailReferente.focus()
		theForm.EmailReferente.select()
		return false;
	}	
	
	if (isEmail(theForm.EmailReferente.value)==false) {
		alert ("L'indirizzo e-mail del referente non e' corretto!")
		theForm.EmailReferente.focus()
		theForm.EmailReferente.select()
		return false;
	}
	
	/* LUOGO PREDEFINITO DI CONSEGNA DEI BENI (SOLO PER I BENEFICIARI) */
	if (document.getElementById('LuogoDiConsegna')) {
	
		if (theForm.ConsegnaIndirizzo.value == "")  {
			alert ("Indirizzo predefinito di consegna dei beni obbligatorio!")
			theForm.ConsegnaIndirizzo.focus()
			theForm.ConsegnaIndirizzo.select()
			return false;
		}
		
		if (theForm.ConsegnaCitta.value == "")  {
			alert ("Citta' predefinita di consegna dei beni obbligatoria!")
			theForm.ConsegnaCitta.focus()
			theForm.ConsegnaCitta.select()
			return false;
		}
		
		if (theForm.ConsegnaidProvincia.value == "")  {
			alert ("Provincia predefinita di consegna dei beni obbligatoria!")
			theForm.ConsegnaidProvincia.focus()
			return false;
		}			
		
		if (theForm.ConsegnaCAP.value == "")  {
			alert ("CAP predefinito di consegna dei beni obbligatorio!")
			theForm.ConsegnaCAP.focus()
			theForm.ConsegnaCAP.select()
			return false;
		}				
	}
	
	return true;														

}
