$(function() { //fCheckObbligatori(); //$('#nominativo').focus(); $(document).bind('keydown', 'Ctrl+n', function() { $('#frmContacts textarea').lorem({ type: 'paragraphs',amount:'4',ptags:false}); $('#frmContacts input[type=checkbox]').attr('checked',true); $('#nominativo').val('Lorem Ipsum'); $('#citta').val('Lorem ipsum dolor sit amet'); $('#telefono').val('+39 000 00000000'); $('#email').val('lorem@ipsum.it'); fCheckObbligatori(); }); $(document).bind('keydown', 'Ctrl+k', function() { $('#frmContacts input[type!=submit]').val(''); $('#frmContacts textarea').html(''); $('#frmContacts input[type=checkbox]').attr('checked',false); fCheckObbligatori(); }); }); function fCheckObbligatori( pintSubmit ) { if ( pintSubmit > 0 ) { $('#oPreload').show(); $('#submitBut').hide(); $('#submitLoad').show(); } var blnReturn = true; var strReturn = ''; $('#errorLog').html(''); //--- nominativo if( ! $('#nominativo').val() ) { blnReturn = false; $('.lblNominativo').addClass('errore'); $('#errorLog').html('Enter the Name field'); $('#nominativo').focus(); } else $('.lblNominativo').removeClass('errore'); //--- email if ( blnReturn && ! $('#email').val() ) { blnReturn = false; $('.lblEmail').addClass('errore'); $('#errorLog').html('Enter the Email field'); $('#email').focus(); } else $('.lblEmail').removeClass('errore'); //--- richiesta if ( blnReturn && ! $('#richiesta').val() ) { blnReturn = false; $('.lblRichiesta').addClass('errore'); $('#errorLog').html('Enter the Request field'); $('#richiesta').focus(); } else $('.lblRichiesta').removeClass('errore'); //--- privacy if ( blnReturn && ( $('#privacy').attr('checked') != null && ! $('#privacy').attr('checked') ) ) { blnReturn = false; $('#errorLog').html('Mandatory acceptance.'); } if ( blnReturn && $('#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'); else { blnReturn = false; $('.lblEmail').addClass('errore'); $("#errorLog").html("The email address is incorrect"); } if ( pintSubmit > 0 ) if ( ! blnReturn ) { $('#oPreload').fadeOut(); $('#submitLoad').hide(); $('#submitBut').show(); $("html,body").animate({scrollTop: 0}, 1500, "bounceout"); } else { //$('#frmContacts').submit(); //--- Ajax : inizio $.ajax({ type: "POST" , url: 'include/ajax/sendContatti.php' , data: 'command=sendContatti' +'&pstrNominativo=' + $('#nominativo').val() +'&pstrCitta=' + $('#citta').val() +'&pstrTelefono=' + $('#telefono').val() +'&pstrEmail=' + $('#email').val() +'&pstrRichiesta=' + $('#richiesta').val() +'&pstrCopy=' + ( $('#copy').attr('checked') ? 'send' : '' ) +'&pstrPrivacy=' + ( $('#privacy').attr('checked') ? 'accept' : '' ) , success: function(data) { // Ritorno : Inizio update = data.split('|'); if( update[0] == 'sendContatti' ) { if( update[1] == 1 ) location.href = 'contacts_thanks.php?copy='+( $('#copy').attr('checked') ? 'send' : '' ); else location.href = 'contacts.php'; } // Ritorno : Fine } }); //--- Ajax : fine } } // Ritorno : Fine } }); //--- Ajax : fine } else { blnReturn = false; if( pintSubmit > 0 ) { $('#oPreload').fadeOut(); $('#submitLoad').hide(); $('#submitBut').show(); $("html,body").animate({scrollTop: 0}, 1500, "bounceout"); } } return false; } function fEvidenziaPrivacy() { $('#box_privacy').hide().fadeIn(); if( ! $('#privacy').attr('checked') ) { blnReturn = false; $('#lblPrivacy').html('Mandatory acceptance.'); } else $('#lblPrivacy').html(''); }