0byt3m1n1
Path:
/
var
/
www
/
listcrawler.app
/
public_html
/
join
/
assets
/
js
/
[
Home
]
File: app.js
$(document).ajaxSend(function() { $("#overlay").fadeIn(300); }); // initialize validation messages variable $.validation = { messages: {} }; // add validation templates to show fancy icons with message text $.extend($.validation.messages, { required: '<i class="fa fa-exclamation-circle"></i> Required.', required_email: '<i class="fa fa-exclamation-circle"></i> Enter your email.', required_password: '<i class="fa fa-exclamation-circle"></i> Choose a password.', email: '<i class="fa fa-exclamation-circle"></i> Please enter a valid email.', minlength: '<i class="fa fa-exclamation-circle"></i> Password should have at least 3 characters.' }); // call our 'validateSignupForm' function when page is ready $(document).ready(function () { validateSignupForm(); }); // bind jQuery validation event and form 'submit' event var validateSignupForm = function () { var form_signup = $('#form_signup'); var signup_result = $('#signup_result'); // bind jQuery validation event form_signup.validate({ rules: { signup_email: { required: true, // email field is required email: true // validate email address }, signup_password: { required: true, // password field is required minlength: 3 // minimum 3 characters } }, messages: { signup_email: { required: $.validation.messages.required_email, email: $.validation.messages.email }, signup_password: { required: $.validation.messages.required_password, minlength: $.validation.messages.minlength } }, errorPlacement: function (error, element) { // insert error message after invalid element error.insertAfter(element); // hide error message on window resize event $(window).resize(function () { error.remove(); }); }, invalidHandler: function (event, validator) { var errors = validator.numberOfInvalids(); if (errors) { } else { } } }); var signup_email = $('#signup_email'); var signup_password = $('#signup_password'); var signup_age = $('#signup_age'); var affiliate_subid = $('#affiliate_subid'); var redirect_url = $('#redirect_url').val(); // bind form submit event form_signup.on('submit', function (e) { // if form is valid then call AJAX script if (form_signup.valid()) { var ajaxRequest = $.ajax({ url: './ajax/signup.php', type: "POST", crossDomain: true, data: { email: signup_email.val(), password: signup_password.val(), age: signup_age.val(), affiliate_subid: affiliate_subid.val(), }, beforeSend: function () { $("#overlay").fadeOut(300); } }); ajaxRequest.fail(function (data, status, errorThrown) { // error var $message = data.responseText; //signup_result.html('<div class="alert alert-danger">' + $message + '</div>'); }); ajaxRequest.done(function (response) { $("#overlay").hide(300); // done //var $response = $.parseJSON(response); //console.log("HELLO = "+response);//return false; if ( (typeof response === "undefined") || (response === null) || (response !== null && response == 'failure') ) { window.location.href = redirect_url; return false; } else if ( response !== null && response == 'invalidemail' ) { signup_result.html('<div class="alert alert-danger">The email is invalid.</div>'); return false; } window.location.href = response; }); } // stop default submit event of form e.preventDefault(); e.stopPropagation(); }); }