var r={
  'notnumbers':/[^\d]/g
}
function valid(o,w){
  o.value = o.value.replace(r[w],'');
}

function AuthorizeValidation(preven) {
	if(preven.accetto.checked == true) {
		preven.invia.disabled = false 
		}
	if(preven.accetto.checked == false) {
	preven.invia.disabled = true 
	}
}

function isEmpty(strfield1, strfield2, strfield3, strfield4) {
strfield1 = document.forms[0].nome.value
strfield2 = document.forms[0].cognome.value
strfield3 = document.forms[0].localita.value
strfield4 = document.forms[0].tel.value

    if (strfield1 == "" || strfield1 == null || !isNaN(strfield1) || strfield1.charAt(0) == ' ')
    {
    alert("Il campo \"NOME\" è un campo obbligatorio.")
    return false;
    }

    if (strfield2 == "" || strfield2 == null || !isNaN(strfield2) || strfield2.charAt(0) == ' ')
    {
    alert("Il campo \"COGNOME\" è un campo obbligatorio.")
    return false;
    }
	
	if (strfield3 == "" || strfield3 == null || !isNaN(strfield3) || strfield3.charAt(0) == ' ')
    {
    alert("Il campo \"LOCALITA'\" è un campo obbligatorio.")
    return false;
    }
	
	if (strfield4 == "" || strfield4 == null || isNaN(strfield4) || strfield4.charAt(0) == ' ')
    {
    alert("Il campo \"TELEFONO\" è un campo obbligatorio.")
    return false;
    }
	
    return true;
}

//function to check valid email address
function isValidEmail(strEmail){
  validRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  strEmail = document.forms[0].email.value;
   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
   {
      alert('Inserisci un indirizzo e-mail valido per il campo \"E-MAIL\"');
      return false;
    } 
    return true; 
}

function provincia(citta){
	citta = document.forms[0].prov.selectedIndex
	if (citta<2){
	alert('Il campo \"PROVINVIA\" è un campo obbligatorio');
	return false;
	}
return true;	
}

function lavoro(tipoi){
	tipoi = document.forms[0].impiego.selectedIndex
	if (tipoi<2){
	alert('Il campo \"IMPIEGO\" è un campo obbligatorio');
	return false;
	}
return true;	
}

//function that performs all functions, defined in the onsubmit event handler
function check(form){
if (isEmpty(form.field1)){
	if (isEmpty(form.field2)){
		if (isEmpty(form.field3)){
			if (isEmpty(form.field4)){
				if (provincia(form.prov)){
					if (lavoro(form.impiego)){
						if (isValidEmail(form.email)){	
			  			return true;
						}
					}
				}
			}
		} 
	}
}
return false;
}