$( function() { $("#frmLogin").submit( function() { if( fCheckObbligatori() ) fSaveData(); return false; }); }); function fSaveData() { fLoading(1); var strTmp = ''; var data; var blnSaved = false; $.ajax({ type: "POST", async: false, dataType: "json", url: "/tpl/default/ajax/loginCliente.php", data: $("#frmLogin").serialize(), success: function(data) { strDestination = data.destination; strTmp = data.status; $('#submitLoad').hide(); if ( data.status == 'ok' ) blnSaved = true; else alert("Registrazione dati non riuscita"); }, error: function(data){ alert("errore: " + data); } }); if ( blnSaved ) { if ( strDestination != '' ) location.href = strDestination; else { $('#loginErrore').show(); fLoading(0); } } else fLoading(0); } // Controlla campi obbligatori login cliente function fCheckObbligatori() { var blnReturn = true; if( $('#txtUsernameCliente').val() == "" ) { blnReturn = false; $('#effect_box').fadeIn(); $('#txtUsernameCliente').focus(); } else if ( $('#txtPasswordCliente').val() == "" ) { blnReturn = false; $('#effect_box').fadeIn(); $('#txtPasswordCliente').focus(); } return blnReturn; }