Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Form Validation & Send Mail code
- */
- $.each($('.vs-contact-form form'), function(index, el) {
- var cform = $(el),
- cResponse = $('<div class="cf_response"></div>');
- cform.prepend(cResponse);
- cform.h5Validate();
- cform.submit(function(e) {
- e.preventDefault();
- // If data-sendmail="0" attribute don;t send any mail, just throw an alert.
- if(cform.attr('data-sendmail') && cform.attr('data-sendmail') == "0") {
- $.magnificPopup.open({
- items: {
- src: '<div class="white-popup">Contact form disabled on demo!</div>',
- type: 'inline'
- },
- closeBtnInside: true
- });
- return;
- }
- if(cform.h5Validate('allValid')) {
- cResponse.hide();
- $.post(
- $(this).attr('action'),
- cform.serialize(),
- function(data){
- cResponse.html(data).fadeIn('fast');
- if(data.match('success') != null) {
- cform.get(0).reset();
- }
- }
- ); // end post
- }
- return false;
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement