$(function() { fCheckObbligatori(); $('#nome').focus(); $(document).bind('keydown', 'Ctrl+n', function() { $('#frmConsulenza textarea').lorem({ type: 'paragraphs',amount:'4',ptags:false}); $('#frmConsulenza input[type=checkbox]').attr('checked',true); $('#nome').val('Lorem'); $('#cognome').val('Ipsum'); $('#indirizzo').val('Lorem ipsum, 10'); $('#cap').val('00000'); $('#citta').val('Sit amet'); $('#provincia')[0].selectedIndex = 1; $('#nazione')[0].selectedIndex = 1; $('#recapito1').val('+39 000 00000000'); $('#recapito2').val('+39 000 00000000'); $('#recapito3').val('+39 000 00000000'); $('#recapito4').val('+39 000 00000000'); $('#email').val('lorem@ipsum.it'); fCheckObbligatori(); }); $(document).bind('keydown', 'Ctrl+k', function() { $('#frmConsulenza input[type!=submit]').val(''); $('#frmConsulenza textarea').html(''); $('#frmConsulenza input[type=checkbox]').attr('checked',false); fCheckObbligatori(); }); }); function fCheckObbligatori( pintSubmit ) { if ( pintSubmit > 0 ) { $('#oPreload').show(); $('#submitBut').hide(); $('#submitLoad').show(); } var blnReturn = true; //--- privacy if( $('#privacy').attr('checked') != null && ! $('#privacy').attr('checked') ) { blnReturn = false; $('#lblPrivacy').html('Mandatory acceptance.'); } else $('#lblPrivacy').html(' '); //--- nome if( ! $('#nome').val() ) { blnReturn = false; $('#lblNome').html('Required'); } else $('#lblNome').html(' '); //--- cognome if( ! $('#cognome').val() ) { blnReturn = false; $('#lblCognome').html('Required'); } else $('#lblCognome').html(' '); //--- indirizzo if( ! $('#indirizzo').val() ) { blnReturn = false; $('#lblIndirizzo').html('Required'); } else $('#lblIndirizzo').html(' '); //--- cap if( ! $('#cap').val() ) { blnReturn = false; $('#lblCap').html('Required'); } else $('#lblCap').html(' '); //--- citta if( ! $('#citta').val() ) { blnReturn = false; $('#lblCitta').html('Required'); } else $('#lblCitta').html(' '); //--- provincia if( ! $('#provincia')[0].selectedIndex ) { blnReturn = false; $('#lblProvincia').html('Required'); } else $('#lblProvincia').html(' '); //--- nazione if( ! $('#nazione')[0].selectedIndex ) { blnReturn = false; $('#lblNazione').html('Required'); } else $('#lblNazione').html(' '); if( $('#email').val() ) { $('#lblEmail').removeClass('errore').addClass('conferma').html('...'); //--- Ajax : inizio $.ajax({ url: 'include/ajax/checkEmail.php' , data: 'command=checkEmail&pstrEmail=' + $('#email').val() , success: function(data) { // Ritorno : Inizio update = data.split('|'); if( update[0] == 'checkEmail' ) { if( update[1] == 1 ) $('#lblEmail').removeClass('errore').addClass('conferma').html("The address seems correct. Ok."); else { blnReturn = false; $('#lblEmail').removeClass('conferma').addClass('errore').html("The address is not correct."); } if ( pintSubmit > 0 ) if ( ! blnReturn ) { $('#oPreload').fadeOut(); $('#submitLoad').hide(); $('#submitBut').show(); $("html,body").animate({scrollTop: 0}, 1500, "bounceout"); } else $('#frmConsulenza').submit(); } // Ritorno : Fine } }); //--- Ajax : inizio } else { blnReturn = false; $('#lblEmail').removeClass('conferma').addClass('errore').html("Required"); if( pintSubmit > 0 ) { $('#oPreload').fadeOut(); $('#submitLoad').hide(); $('#submitBut').show(); $("html,body").animate({scrollTop: 0}, 1500, "bounceout"); } } return blnReturn; } function fEvidenziaPrivacy() { if ( $('#box_privacy').hasClass('fprivacy') ) $('#box_privacy').hide().removeClass('fprivacy').addClass('fprivacyon').fadeIn('slow'); else $('#box_privacy').hide().removeClass('fprivacyon').addClass('fprivacy').fadeIn('slow'); if( ! $('#privacy').attr('checked') ) { blnReturn = false; $('#lblPrivacy').html('Mandatory acceptance.'); } else $('#lblPrivacy').html(''); }