2013-08-05 09:29:54 +00:00
|
|
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
|
|
|
|
// License: GNU General Public License v3. See license.txt
|
|
|
|
|
2012-12-27 13:10:42 +00:00
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
|
|
$('.btn-send').click(function() {
|
|
|
|
var email = $('[name="email"]').val();
|
|
|
|
var message = $('[name="message"]').val();
|
|
|
|
|
|
|
|
if(!(email && message)) {
|
|
|
|
msgprint("Please enter both your email and message so that we \
|
|
|
|
can get back to you. Thanks!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!valid_email(email)) {
|
|
|
|
msgprint("You seem to have written your name instead of your email. \
|
|
|
|
Please enter a valid email address so that we can get back.");
|
|
|
|
$('[name="email"]').focus();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#contact-alert").toggle(false);
|
|
|
|
erpnext.send_message({
|
|
|
|
subject: $('[name="subject"]').val(),
|
|
|
|
sender: email,
|
|
|
|
message: message,
|
|
|
|
callback: function(r) {
|
2013-08-29 08:23:36 +00:00
|
|
|
if(r.status==="okay") {
|
2013-08-31 06:01:18 +00:00
|
|
|
msgprint(r.message || "Thank you for your message.")
|
2013-08-29 08:23:36 +00:00
|
|
|
} else {
|
|
|
|
msgprint("There were errors");
|
|
|
|
console.log(r.exc);
|
|
|
|
}
|
2012-12-27 13:10:42 +00:00
|
|
|
$(':input').val('');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
var msgprint = function(txt) {
|
|
|
|
if(txt) $("#contact-alert").html(txt).toggle(true);
|
|
|
|
}
|