In this repo i store all my websites, each in a different branch
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
2.2 KiB

  1. (function ($) {
  2. "use strict";
  3. $("#contact").validate();
  4. /* =================================
  5. === CONTACT FORM ====
  6. =================================== */
  7. $("#contact").submit(function (e) {
  8. e.preventDefault();
  9. var name = $("#form-name").val();
  10. var email = $("#form-email").val();
  11. var subject = $("#form-subject").val();
  12. var message = $("#form-message").val();
  13. var dataString = 'name=' + name + '&email=' + email + '&subject=' + subject + '&message=' + message;
  14. function validEmail(emailAddress) {
  15. var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
  16. return pattern.test(emailAddress);
  17. };
  18. if (validEmail(email) && (message.length > 1) && (name.length > 1)) {
  19. $.ajax({
  20. type: "POST",
  21. url: "send-mail.php",
  22. data: dataString,
  23. success: function () {
  24. $('.successContent').fadeIn(1000);
  25. $('.errorContent').fadeOut(500);
  26. }
  27. });
  28. }
  29. else {
  30. $('.errorContent').fadeIn(1000);
  31. $('.successContent').fadeOut(500);
  32. }
  33. return false;
  34. });
  35. })(jQuery);