brotherton-erpnext/website/templates/js/contact.js

46 lines
1.1 KiB
JavaScript
Raw Normal View History

// 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) {
if(r.status==="okay") {
msgprint(r.message or "Sent")
} 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);
}