From 5f893a99145fc9b70b142f63445ac66bc9b1fb2e Mon Sep 17 00:00:00 2001 From: Horus3 Date: Fri, 29 May 2015 20:31:29 +0200 Subject: Sanitize Title input before saving. --- static/js/app.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'static/js') 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); -- cgit v1.2.3