bux23
7/12/2016 - 3:10 PM

Jquery check on input fields and phone number for ios

Jquery check on input fields and phone number for ios

$("form").submit(function(e) {
		
		var ref = $(this).find("[required]");

	    $(ref).each(function(){
		    var VAL = $(this).val();
		    var istel = new RegExp('/^([0-9]{8,9})$');
		    if ( VAL == '' )
	        {
	            alert("Compilare tutti i campi");
	
	            $(this).focus();
	
	            e.preventDefault();
	            return false;
	        }
	        if ( $(this).is('#tel') && (isNaN(VAL) || VAL.length < 9 || VAL.length > 10 ))
	        {
	            alert("Inserire un recapito telefonico valido");
	
	            $(this).focus();
	
	            e.preventDefault();
	            return false;
	        }
	        
	    });  return true;
	});