Rushabh Mehta | d616413 | 2012-12-27 18:40:42 +0530 | [diff] [blame] | 1 | $(document).ready(function() { |
| 2 | |
| 3 | $('.btn-send').click(function() { |
| 4 | var email = $('[name="email"]').val(); |
| 5 | var message = $('[name="message"]').val(); |
| 6 | |
| 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 | |
| 13 | if(!valid_email(email)) { |
| 14 | msgprint("You seem to have written your name instead of your email. \ |
| 15 | Please enter a valid email address so that we can get back."); |
| 16 | $('[name="email"]').focus(); |
| 17 | return false; |
| 18 | } |
| 19 | |
| 20 | $("#contact-alert").toggle(false); |
| 21 | erpnext.send_message({ |
| 22 | subject: $('[name="subject"]').val(), |
| 23 | sender: email, |
| 24 | message: message, |
| 25 | callback: function(r) { |
| 26 | msgprint(r.message); |
| 27 | $(':input').val(''); |
| 28 | } |
| 29 | }); |
| 30 | return false; |
| 31 | }); |
| 32 | |
| 33 | }); |
| 34 | |
| 35 | var msgprint = function(txt) { |
| 36 | if(txt) $("#contact-alert").html(txt).toggle(true); |
| 37 | } |