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.
 
 
 
 
 
 

46 lines
1.1 KiB

  1. // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
  2. // MIT License. See license.txt
  3. $(document).ready(function() {
  4. $('.btn-send').click(function() {
  5. var email = $('[name="email"]').val();
  6. var message = $('[name="message"]').val();
  7. if(!(email && message)) {
  8. msgprint("Please enter both your email and message so that we \
  9. can get back to you. Thanks!");
  10. return false;
  11. }
  12. if(!valid_email(email)) {
  13. msgprint("You seem to have written your name instead of your email. \
  14. Please enter a valid email address so that we can get back.");
  15. $('[name="email"]').focus();
  16. return false;
  17. }
  18. $("#contact-alert").toggle(false);
  19. wn.send_message({
  20. subject: $('[name="subject"]').val(),
  21. sender: email,
  22. message: message,
  23. callback: function(r) {
  24. if(r.status==="okay") {
  25. msgprint(r.message || "Thank you for your message.")
  26. } else {
  27. msgprint("There were errors");
  28. console.log(r.exc);
  29. }
  30. $(':input').val('');
  31. }
  32. }, this);
  33. return false;
  34. });
  35. });
  36. var msgprint = function(txt) {
  37. if(txt) $("#contact-alert").html(txt).toggle(true);
  38. }