/* Script : Contact Form Version : 1.0 Author : Surjith S M URI : http://themeforest.net/user/surjithctly Copyright © All rights Reserved Surjith S M / @surjithctly */ $(function() { "use strict"; /* ================================================ jQuery Validate - Reset Defaults ================================================ */ $.validator.setDefaults({ ignore: [], highlight: function(element) { $(element).closest('.form-group').addClass('has-error'); }, unhighlight: function(element) { $(element).closest('.form-group').removeClass('has-error'); }, errorElement: 'small', errorClass: 'help-block', errorPlacement: function(error, element) { if (element.parent('.input-group').length || element.parent('label').length) { error.insertAfter(element.parent()); } else { error.insertAfter(element); } } }); /* VALIDATE -------- */ $("#contact_form").submit(function(e) { e.preventDefault(); }).validate({ rules: { name: "required", email: { required: true, email: true } }, submitHandler: function(form) { $("#js-contact-btn").attr("disabled", true); /* CHECK PAGE FOR REDIRECT (Thank you page) ---------------------------------------- */ var redirect = $('#contact_form').data('redirect'); var phpurl = $('#contact_form').attr('action'); var noredirect = false; if (redirect == 'none' || redirect == "" || redirect == null) { noredirect = true; } $("#js-contact-btn").attr("disabled", true); $('#js-contact-result').fadeIn('slow').html('