

function _CF_onError(form_object, input_object, object_value, error_message)
    {
	alert(error_message);
       	return false;	
    }



function _CF_hasValue(obj, obj_type)
    {
    if (obj_type == "TEXT" || obj_type == "PASSWORD")
	{
    	if (obj.value.length == 0) 
      		return false;
    	else 
      		return true;
    	}
    else if (obj_type == "SELECT")
	{
        for (i=0; i < obj.length; i++)
	    	{
		if (obj.options[i].selected)
			return true;
		}

       	return false;	
	}
    else if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX")
	{

		if (obj.checked)
			return true;
		else
       		return false;	
	}
    else if (obj_type == "RADIO" || obj_type == "CHECKBOX")
	{

        for (i=0; i < obj.length; i++)
	    	{
		if (obj[i].checked)
			return true;
		}

       	return false;	
	}
	}



function _CF_checkregex(object_value, regex)
	{
	//Returns true if the value matches the Regular Expression passed in.
	
	return regex.test(object_value);

	}


function  _CF_checkCFForm_1(_CF_this)

    {

    if  (!_CF_hasValue(_CF_this.nome, "TEXT" )) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.nome, _CF_this.nome.value, "manca la compilazione del campo nome!"))

            {

            return false; 

            }

        }


    if  (!_CF_hasValue(_CF_this.azienda, "TEXT" )) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.azienda, _CF_this.azienda.value, "manca la compilazione del campo Azienda"))

            {

            return false; 

            }

        }


    if  (!_CF_checkregex(_CF_this.email.value, /^[A-Za-z0-9\._-]+@([0-9a-zA-Z][0-9A-Za-z_-]+\.)+[a-z]{2,4}$/))

        {

        if  (!_CF_onError(_CF_this, _CF_this.email, _CF_this.email.value, "inserire un indirizzo e-mail valido"))

            {

            return false; 

            }

        }


    if  (!_CF_hasValue(_CF_this.legge, "SINGLE_VALUE_RADIO" )) 

        {

        if  (!_CF_onError(_CF_this, _CF_this.legge, _CF_this.legge.value, "senza il consenso al trattamento dei dati non è possibile inviare i dati. Clicca su: sì, acconsento"))

            {

            return false; 

            }

        }


    return true;

    }
