Forums

ReCaptcha problem with save data to DB

fasenderos 15 May, 2012
Hi to all,

I have a problem with recaptcha... I think that the problem is caused by my LoadJS...in this event i created some rules to Hide/Show and Enable/Disabled (the required field) depending on the user action.
If you enter a wrong verification code, the form reload with the data previosly inserted, but not all the data are reloaded, and the rules to Hide/Show are diametrically opposed...infact what before was Show and Required, after the reload is Hidden and not Required ...so the user can simply retype the verification code and sent the form with many missing data 😟

that's the LoadJS code:

window.addEvent('domready', function() {
    var servizio, fatture, fatture_div, paghe, paghe_div, contabilita_div, corrispettivi_div, semplificata, ordinaria, corrispettivi_si, corrispettivi_no;

    servizio = $$('#servizio_container_div input');

    fatture_div = $('numero_fatture_annue_container_div');
    fatture = $('numero_fatture_annue');

    paghe_div = $('numero_di_dipendenti_container_div');
    paghe = $('numero_di_dipendenti');

    contabilita_div = $('contabilita_container_div');
    contabilita_div.setStyle('display', 'none');

    corrispettivi_div = $('corrispettivi_container_div');
    corrispettivi_div.setStyle('display', 'none');

    fatture_div.setStyle('display', 'none');
    fatture.disabled = true;
    fatture.value = '';

    paghe_div.setStyle('display', 'none');
    paghe.disabled = true;
    paghe.value = '';
 
    semplificata = $('contabilita_contabilita_semplificata');
    ordinaria = $('contabilita_contabilita_ordinaria');
    corrispettivi_si = $('corrispettivi_si');
    corrispettivi_no = $('corrispettivi_no');

    semplificata.disabled = true;
    ordinaria.disabled = true;
    corrispettivi_si.disabled = true;
    corrispettivi_no.disabled = true;
    
    var check1 = false;
    var check2 = false;
    var check3 = false;
    var check4 = false;
  
    servizio.each(function(item) {
        item.addEvent('click', function(){
            if ( this.value == 'Contabilita_Classica') {
            	if(check1==false) check1=true;
            	else check1=false;
            }else if ( this.value == 'Contabilita_Online') {
            	if(check2==false) check2=true;
            	else check2=false;
            }else if ( this.value == 'Contabilita_Fai_Da_Te') {
            	if(check3==false) check3=true;
            	else check3=false;
            }else if ( this.value == 'Elaborazioni_Paghe') {
            	if(check4==false) check4=true;
            	else check4=false;
            }
 
             if(check1==true || check2==true || check3==true){            	
            	fatture_div.setStyle('display', 'block');
                fatture.disabled = false;

                contabilita_div.setStyle('display', 'block');
                corrispettivi_div.setStyle('display', 'block');  

                semplificata.disabled = false;
                ordinaria.disabled = false;

                corrispettivi_si.disabled = false;
                corrispettivi_no.disabled = false;
            }
            else if(check1==false && check2==false && check3==false){
         	fatture_div.setStyle('display', 'none');
                fatture.disabled = true;

                contabilita_div.setStyle('display', 'none');
                corrispettivi_div.setStyle('display', 'none');  
    
                semplificata.disabled = true;
                ordinaria.disabled = true;
    
                corrispettivi_si.disabled = true;
                corrispettivi_no.disabled = true;
            }
            if(check4==true){            	
            	paghe_div.setStyle('display', 'block');
                paghe.disabled = false;                
            }
          	else if(check4==false){
       		paghe_div.setStyle('display', 'none');
                paghe.disabled = true;
            }   

        });

    });

});


And here is the link to my form

Events List

On Load:
Load ReCaptha
Load JS
Load CSS
Show HTML

On Submit:
Checke ReCaptcha
--On Fail, Event Loop
Hendle Arrays
DB Save
Show Thanks Message


Thanks to all
GreyHead 15 May, 2012
Hi fasenderos ,

I haven't looked at the code in detail but I think you are correct. You need to edit the code so that it check if any values are already set and show or hides the corresponding boxes. This has to be done carefully so that you don't erase any of the values.

The ChronoForms republisher will just add in the values that it finds, it doesn't know anything about validation or about hidden inputs.

Bob
fasenderos 15 May, 2012

You need to edit the code so that it check if any values are already set and show or hides the corresponding boxes. This has to be done carefully so that you don't erase any of the values.



Hi bob,
can you make me an example?

Thanks
Andrea
This topic is locked and no more replies can be posted.