Guest User

Untitled

a guest
Feb 10th, 2015
220
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. * Form Validation & Send Mail code
  3. */
  4. $.each($('.vs-contact-form form'), function(index, el) {
  5. var cform = $(el),
  6. cResponse = $('<div class="cf_response"></div>');
  7. cform.prepend(cResponse);
  8. cform.h5Validate();
  9.  
  10. cform.submit(function(e) {
  11. e.preventDefault();
  12. // If data-sendmail="0" attribute don;t send any mail, just throw an alert.
  13. if(cform.attr('data-sendmail') && cform.attr('data-sendmail') == "0") {
  14. $.magnificPopup.open({
  15. items: {
  16. src: '<div class="white-popup">Contact form disabled on demo!</div>',
  17. type: 'inline'
  18. },
  19. closeBtnInside: true
  20. });
  21. return;
  22. }
  23.  
  24. if(cform.h5Validate('allValid')) {
  25. cResponse.hide();
  26. $.post(
  27. $(this).attr('action'),
  28. cform.serialize(),
  29. function(data){
  30. cResponse.html(data).fadeIn('fast');
  31. if(data.match('success') != null) {
  32. cform.get(0).reset();
  33. }
  34. }
  35. ); // end post
  36. }
  37. return false;
  38. });
  39. });
RAW Paste Data