function Register() { this.server_page = "/include_user/php/subscribe.php"; this.fields = new Array(); this.fields.push({id:"username", required:true, pattern:/^[a-zA-Z0-9_-]{3,}$/, message:"Nome Utente non valido (min. 3 caratteri)."}); this.fields.push({id:"userpass", required:true, pattern:/^[a-zA-Z0-9\u00C0-\u00F6\u00F8-\u00FF]{8,}$/, message:"Password non valida (min. 8 caratteri alfanumerici)."}); this.fields.push({id:"email", required:true, pattern:/^([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})){1}$/, message:"Indirizzo e-mail non valido."}); this.fields.push({id:"nome", required:true, pattern:/^[A-Za-z\u00C0-\u00F6\u00F8-\u00FF ]{3,}$/, message:"Nome non valido."}); this.fields.push({id:"cognome", required:true, pattern:/^[A-Za-z\u00C0-\u00F6\u00F8-\u00FF'′’‘ ]{3,}$/, message:"Cognome non valido."}); this.fields.push({id:"ragionesociale", required:false, pattern:/^[A-Za-z0-9.-\u00C0-\u00F6\u00F8-\u00FF ]{3,}$/, message:"Ragione sociale non valida."}); this.fields.push({id:"partitaiva", required:false, pattern:/^[a-zA-Z0-9_-]{3,}$/, message:"Partita IVA non valida."}); this.fields.push({id:"codicefiscale", required:true, pattern:/^[a-zA-Z0-9_-]{3,}$/, message:"Codice fiscale non valido."}); this.fields.push({id:"codicesdi", required:false, pattern:/^[A-Za-z0-9]{7}$/, message:"Codice univoco SDI non valido. Deve essere di 7 caratteri alfanumerici."}); this.fields.push({id:"pec", required:false, pattern:/^([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})){1}$/, message:"Indirizzo PEC non valido."}); this.fields.push({id:"indirizzo", required:true, pattern:/^[a-zA-Z0-9,′’‘\/'\u00C0-\u00F6\u00F8-\u00FF\. ]{5,}$/, message:"Indirizzo non valido."}); this.fields.push({id:"cap", required:false, pattern:/^[0-9]{5}$/, message:"CAP non valido."}); this.fields.push({id:"localita", required:true, pattern:/^[A-Za-z0-9\u00C0-\u00F6\u00F8-\u00FF'′’‘ ]{2,}$/, message:"Localit\u00E0 non valida."}); this.fields.push({id:"provincia", required:true, pattern:/^[A-Za-z0-9\u00C0-\u00F6\u00F8-\u00FF'′’‘ ]{2,}$/, message:"Provincia non valida."}); this.fields.push({id:"nazione", required:true, pattern:/^[A-Za-z0-9\u00C0-\u00F6\u00F8-\u00FF'′’‘ ]{2,}$/, message:"Nazione non valida."}); this.fields.push({id:"telefonoprincipale", required:true, pattern:/^.{0,}$/, message:"Telefono fisso non valido."}); this.fields.push({id:"telefonocellulare", required:true, pattern:/^[a-zA-Z0-9+\-,\/'\u00C0-\u00F6\u00F8-\u00FF ]{5,}$/, message:"Cellulare non valido."}); this.fields.push({id:"fax", required:false, pattern:/^.{0,}$/, message:"Fax non valido."}); this.submit = function(standalone) { var htmlError = new String('

Errore

'); var errors = false; for (var i = 0; i < this.fields.length; i++) { var element = document.getElementById(this.fields[i].id); var check = new String(element.value); var field_error = false; var check_piva_cf = true; if (this.fields[i].required && !check.match(this.fields[i].pattern) && check_piva_cf) { element.style.color = "red"; htmlError += '

' + this.fields[i].message + '

'; errors = true; field_error = true; } else { //Controlla che i campi Codice SDI e PEC siano verificati solo se valorizzati if(check != '' && (this.fields[i].id == 'pec' || this.fields[i].id == 'codicesdi')) { if(!check.match(this.fields[i].pattern)){ element.style.color = "red"; htmlError += '

' + this.fields[i].message + '

'; errors = true; field_error = true; }else{ element.style.color = ""; this.params[this.fields[i].id] = check; console.log(this.fields[i].id+' -> '+check); } }else{ element.style.color = ""; this.params[this.fields[i].id] = check; console.log(this.fields[i].id+' -> '+check); } } } var cond = document.getElementById('condizioni'); if (!cond.checked) { errors = true; htmlError += '

Accetta le condizioni generali di vendita.

'; } var privacy = document.getElementById('privacy'); if (!privacy.checked) { errors = true; htmlError += '

Autorizza il trattamento dei dati personali.

'; } htmlError += '
'; if (errors) { // SCROLL TOP $('html,body').animate({scrollTop: 130}, function () { $.fancybox.open(htmlError, {type: 'inline', autoSize: true, autoWidth: true, autoHeight: true, autoResize: true}); }); return; } this.params["profilo"] = document.getElementById("profilo").value; this.params["condizioni"] = 1; this.params["privacy"] = 1; this.params["standalone"] = standalone; var newslett = document.getElementById('newslett'); if (!newslett.checked) { this.params["newslett"] = 0; }else{ this.params["newslett"] = 1; } document.getElementById("php_response").style.backgroundColor = ''; this.setLoadingTarget(document.getElementById("php_response")); this.setTarget(this.handle_response); this.makeRequest(this.server_page); } this.handle_response = function(response) { var vars = decodeUrlVars(response); var message = decodeURIComponent(vars['message']); var success = decodeURIComponent(vars['success']) == true ? true : false; var success1 = decodeURIComponent(vars['success1']) == 'true' ? true : false; var standalone = decodeURIComponent(vars['standalone']); var htmlMessage = new String('
'); document.getElementById("php_response").innerHTML = ''; if (!success1) { htmlMessage += '

Errore

'; htmlMessage += '

' + message + '

'; // SCROLL TOP $('html,body').animate({scrollTop: 100}, function () { $.fancybox.open(htmlMessage, {type: 'inline', autoSize: true, autoWidth: true, autoHeight: true, autoResize: true}); }); } else { htmlMessage += message + ''; if(standalone == 1){ targetPage = '/register-complete'; }else if(standalone == 2){ if(document.getElementById("lang").value == 2) { targetPage = '/en/payonline'; }else{ targetPage = '/pagaonline'; } }else{ targetPage = '/info-cliente' } $.fancybox.open(htmlMessage, {type: 'inline', autoSize: true, autoWidth: true, autoHeight: true, autoResize: true, afterClose: function() { window.location.replace(targetPage) } }); } } } Register.prototype = new AjaxModule(); Register.prototype.constructor = Register; var regobj = new Register(); function Iscriviti() { this.server_page = "/include_user/php/iscriviti.php"; this.fields = new Array(); this.fields.push({id:"username", pattern:/^[a-zA-Z0-9_-]{3,}$/, message:"Nome Utente non valido (min. 3 caratteri)."}); this.fields.push({id:"userpass", pattern:/^[a-zA-Z0-9\u00C0-\u00F6\u00F8-\u00FF]{8,}$/, message:"Password non valida (min. 8 caratteri alfanumerici)."}); this.fields.push({id:"email", pattern:/^([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})){1}$/, message:"Indirizzo e-mail non valido."}); this.fields.push({id:"nome", pattern:/^[A-Za-z\u00C0-\u00F6\u00F8-\u00FF ]{3,}$/, message:"Nome non valido."}); this.fields.push({id:"cognome", pattern:/^[A-Za-z\u00C0-\u00F6\u00F8-\u00FF'′’‘ ]{3,}$/, message:"Cognome non valido."}); this.fields.push({id:"codicefiscale", required:true, pattern:/^[A-Za-z0-9\u00C0-\u00F6\u00F8-\u00FF' ]{2,}$/, message:"Codice fiscale non valido."}); this.fields.push({id:"indirizzo", pattern:/^[a-zA-Z0-9,′’‘\/'\u00C0-\u00F6\u00F8-\u00FF ]{5,}$/, message:"Indirizzo non valido."}); this.fields.push({id:"cap", pattern:/^[0-9]{5}$/, message:"CAP non valido."}); this.fields.push({id:"localita", pattern:/^[A-Za-z0-9\u00C0-\u00F6\u00F8-\u00FF'′’‘ ]{2,}$/, message:"Localit\u00E0 non valida."}); this.fields.push({id:"provincia", pattern:/^[A-Za-z0-9\u00C0-\u00F6\u00F8-\u00FF'′’‘ ]{2,}$/, message:"Provincia non valida."}); this.fields.push({id:"telefonoprincipale", pattern:/^.{0,}$/, message:"Telefono fisso non valido."}); this.fields.push({id:"telefonocellulare", pattern:/^.{0,}$/, message:"Cellulare non valido."}); this.submit = function() { for (var i = 0; i < this.fields.length; i++) { var check = new String(document.getElementById(this.fields[i].id).value); if (!check.match(this.fields[i].pattern)) { document.getElementById(this.fields[i].id).style.borderColor = "red"; document.getElementById(this.fields[i].id).style.color = "black"; document.getElementById(this.fields[i].id).focus(); document.getElementById(this.fields[i].id + "_response").style.color = "black"; document.getElementById(this.fields[i].id + "_response").innerHTML = this.fields[i].message; // SCROLL TOP $('html,body').animate({scrollTop:180}, 500); return; } else { document.getElementById(this.fields[i].id).style.borderColor = "green"; document.getElementById(this.fields[i].id).style.color = "black"; document.getElementById(this.fields[i].id + "_response").innerHTML = ""; this.params[this.fields[i].id] = check; } } var cond = document.getElementById('condizioni'); if (!cond.checked) { alert("Accetta le condizioni generali di vendita."); return; } var privacy = document.getElementById('privacy'); if (!privacy.checked) { alert("Autorizza il trattamento dei dati personali."); return; } this.params["ragionesociale"] = document.getElementById("ragionesociale").value; this.params["partitaiva"] = document.getElementById("partitaiva").value; this.params["fax"] = document.getElementById("fax").value; this.params["profilo"] = document.getElementById("profilo").value; this.params["condizioni"] = 1; this.params["privacy"] = 1; document.getElementById("php_response").style.backgroundColor = ''; this.setLoadingTarget(document.getElementById("php_response")); this.setTarget(this.handle_response); this.makeRequest(this.server_page); } this.handle_response = function(response) { response = decodeUrlVars(response); if (response['success'] == 'no') { document.getElementById("php_response").innerHTML = ''; if (document.getElementById(response['fieldid'])) document.getElementById(response['fieldid']).style.borderColor = 'red'; // SCROLL TOP $('html,body').animate({scrollTop:180}, 500); } document.getElementById(response['fieldid'] + "_response").innerHTML = decodeURIComponent(response['message']); } } Iscriviti.prototype = new AjaxModule(); Iscriviti.prototype.constructor = Iscriviti; var iscobj = new Iscriviti();