summaryrefslogtreecommitdiff
path: root/static/js
diff options
context:
space:
mode:
authorHorus32015-05-29 20:31:29 +0200
committerHorus32015-05-29 20:31:29 +0200
commit5f893a99145fc9b70b142f63445ac66bc9b1fb2e (patch)
tree0d11b8eb73b1beb29c0f6eb7e2445df4d0fe94dd /static/js
parent57fd242908857312d304726d128cd8293c1b015a (diff)
downloadscribbled-5f893a99145fc9b70b142f63445ac66bc9b1fb2e.tar.gz
Sanitize Title input before saving.
Diffstat (limited to 'static/js')
-rw-r--r--static/js/app.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/static/js/app.js b/static/js/app.js
index 4abf214..7efe1c7 100644
--- a/static/js/app.js
+++ b/static/js/app.js
@@ -26,6 +26,18 @@ function registerAutosave(id){
// Function to save memo
function save(id, manually){
+ if ( !$('#Title').val().trim() ){
+ swal({
+ title: "Title required",
+ text: "In order to save please enter a title.",
+ type: "warning",
+ confirmButtonClass: "btn-danger",
+ confirmButtonText: "Close",
+ closeOnConfirm: false,
+ });
+ return;
+ }
+
$.ajax({
url: "/api/new",
data: $(id).serialize(),
@@ -120,6 +132,18 @@ $(document).ready(function(){
};
$('#autosave').click(function() {
+ if ( !$('#Title').val().trim() ){
+ swal({
+ title: "Title required",
+ text: "In order to save please enter a title.",
+ type: "warning",
+ confirmButtonClass: "btn-danger",
+ confirmButtonText: "Close",
+ closeOnConfirm: false
+ });
+ return;
+ }
+
$(this).toggleClass("btn-danger").promise().done(function(){
if ( $(this).html().match(/Enable/) ){
registerAutosave(this);