frases = new Array();frases[1] = "Error"; frases[2] = "Please review the fields marked in red"; frases[3] = "Sending..."; frases[4] = "Sending the message"; frases[5] = "Success!"; frases[6] = "Message successfully sent!";msg = "en";function fn_submit(form){ errors = 0; $("#"+form+" *").filter(':input').each(function(){ $(this).removeClass("error"); var attr = $(this).attr('data-required'); if (typeof attr !== typeof undefined && attr !== false) { if(attr == 's'){ if($(this).attr('data-type') == 'select'){ if($(this).val() == 0){ $(this).addClass("error"); errors++; } } else { if($(this).val() == ''){ $(this).addClass("error"); errors++; } } } } var attr2 = $(this).attr('data-type'); if (typeof attr2 !== typeof undefined && attr2 !== false) { if(attr2 == 'mail'){ if(!(validateEmail($(this).val()))){ $(this).addClass("error"); errors++; } } } var attr3 = $(this).attr('data-check'); if (typeof attr3 !== typeof undefined && attr3 !== false) { obj2 = $("#"+$(this).attr('data-check')) if($(this).val() != obj2.val()){ $(this).addClass("error"); obj2.addClass("error"); errors++; } } }); // each if(errors > 0 ){ fn_alert("error", frases[1],frases[2]); return; } post_to = $("#"+form).attr("data-action"); fn_alert("warning", frases[3], frases[4]); $.post(post_to, $("#"+form).serialize(), function(data) { if(data){ console.log(data); fn_alert("success", frases[5], frases[6]); } }); } // eof function fn_alert(tipo, titulo, msg) { modal({ type: tipo, //Type of Modal Box (alert | confirm | prompt | success | warning | error | info | inverted | primary) title: titulo, //Modal Title text: msg, //Modal HTML Content size: 'normal', //Modal Size (normal | large | small) buttons: [{ text: 'OK', //Button Text val: 'ok', //Button Value eKey: true, //Enter Keypress addClass: 'btn-light-blue', //Button Classes (btn-large | btn-small | btn-green | btn-light-green | btn-purple | btn-orange | btn-pink | btn-turquoise | btn-blue | btn-light-blue | btn-light-red | btn-red | btn-yellow | btn-white | btn-black | btn-rounded | btn-circle | btn-square | btn-disabled) onClick: function(dialog) { //console.log(dialog); //alert('Look in console!'); return true; } }, ], center: true, //Center Modal Box? autoclose: false, //Auto Close Modal Box? callback: null, //Callback Function after close Modal (ex: function(result){alert(result); return true;}) onShow: function(r) {}, //After show Modal function closeClick: true, //Close Modal on click near the box closable: true, //If Modal is closable theme: 'atlant', //Modal Custom Theme (xenon | atlant | reseted) animate: false, //Slide animation background: 'rgba(0,0,0,0.35)', //Background Color, it can be null zIndex: 1050, //z-index buttonText: { ok: 'OK', yes: 'Yes', cancel: 'Cancel' }, template: '', _classes: { box: '.modal-box', boxInner: ".modal-inner", title: '.modal-title', content: '.modal-text', buttons: '.modal-buttons', closebtn: '.modal-close-btn' } }); } function getQueryVariable(variable, string) { var vars = string.split("&"); for (var i=0;i()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); }