function ckFrm_empty(campo,allerta){var re=/[\s]/g;var str=campo.value.replace(re,'');if(str==""){if(allerta!=null){alert(allerta);}else{alert("Attenzione: il campo è vuoto!");};campo.focus();return false;};return true;}

function ckFrm_empty2(campo){var re=/[\s]/g;var str=campo.value.replace(re,'');if(str==""){return false;};return true;}

function ckFrm_number(campo,allerta){if(isNaN(campo.value)){if(allerta!=null){alert(allerta);}else{alert("Attenzione: il campo non è un numero!");};campo.focus();return false;};return true;}

function ckFrm_maxlength(campo,lunghezza,allerta){if(campo.value.length > lunghezza){if(allerta!=null){alert(allerta);}else{alert("Attenzione: la dimensione del campo supera i "+lunghezza+" caratteri!");};campo.focus();return false;};return true;}

function ckFrm_selected(campo,allerta){var re=/[\s]/g;var str=campo.options[campo.selectedIndex].value.replace(re,"");if(str==""){if(allerta!=null){alert(allerta);}else{alert("Attenzione: seleziona la tua scelta!");};campo.focus();return false;};return true;}

function ckFrm_filled(campo,valore,allerta){if(campo.value==valore){if(allerta!=null){alert(allerta);};campo.focus();return false;};return true;}

function ckFrm_isDate(campo,allerta){var regiornomese=new Array(2);var ok=true;var strdata=campo.value;var redata=new RegExp('^([0][1-9]|[1-2][0-9]|[3][0-1])[\/]([0][1-9]|[1][0-2])[\/](19|20)[0-9]{2}$');regiornomese[0]=new RegExp('^(((0[1-9]|1[0-9]|2[0-8])[\/]02)|((0[1-9]|[12][0-9]|30)[\/](04|06|09|11))|((0[1-9]|[12][0-9]|30|31)[\/](01|03|05|07|08|10|12)))$');regiornomese[1]=new RegExp('^(((0[1-9]|1[0-9]|2[0-9])[\/]02)|((0[1-9]|[12][0-9]|30)[\/](04|06|09|11))|((0[1-9]|[12][0-9]|30|31)[\/](01|03|05|07|08|10|12)))$');if(strdata.search(redata) == -1){ok=false;}else{anno=strdata.substring(6,10);giornomese=strdata.substring(0,5);anno1=anno.substring(0,2);anno2=anno.substring(2,4);bisestile=0;if((parseInt(anno/4) == anno/4) && ((anno2 != '00') || ((anno2 == '00') && (parseInt(anno1/4) == anno1/4)))){bisestile=1;};if(giornomese.search(regiornomese[bisestile]) == -1){ok=false;}};if(!ok){if(allerta!=null){alert(allerta);}else{alert("Attenzione: inserire la data nel formato gg/mm/aaaa");};campo.focus();return false;};return true;}

function ckFrm_email(campo,allerta){value=campo.value;pattern=/[^@_\-\.\w\d]|@@|\.\.|__|^@|^\.|^_|@$|\.$|_$|@\.|\.@|\._|_\.|(@)[^@]*\1/g;if((((value.match(/@/)) && (value.match(/\./))) == null) || (value.match(pattern) != null)){if(allerta!=null){alert(allerta);}else{alert("Attenzione: l'indirizzo email inserito non è corretto!");};campo.focus();return false;};return true;}

function ckFrm_radio(campo,allerta){var found=false;for(var j=0;j<campo.length;j++){if(campo[j].checked){found=true;break;}};if(!found){if(allerta!=null){alert(allerta);}else{alert("Attenzione: seleziona la tua scelta!");};return false;};return true;}

function ckFrm_radio2(campo){var found=false;for(var j=0;j<campo.length;j++){if(campo[j].checked){found=true;break;}};if(!found){return false;};return true;}

function ckFrm_checkbox(campo,allerta){
	alert(campo);
if(!campo.checked){if(allerta!=null){alert(allerta);}else{alert("Attenzione: seleziona la tua scelta!");};return false;};return true;}

function ckFrm_checkbox2(campo,allerta){
	
	check = false;
	
	for( i=0; i < campo.length; i++)
	 {
	 	if  (campo[i].checked == true) {
		 			
		 			check = true;
		 }
	 }
	if(!check){ 
		 	if(allerta!=null){
			 	alert(allerta);
			} else {
					alert("Attenzione: seleziona la tua scelta!");
			}
		 } else return true;
}


