From 0013b40a609959c10cf0af8dce84881686397687 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Thu, 1 May 2014 14:06:50 -0500 Subject: [PATCH] js: Don't crash if no date set in a datepicker --- scp/js/scp.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scp/js/scp.js b/scp/js/scp.js index 780d4c41a..fefbe26bc 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -303,8 +303,9 @@ $(document).ready(function(){ $(document).on('submit', 'form', function() { $('.dp', $(this)).each(function(i, e) { var $e = $(e), - d = $e.datepicker('getDate'), - day = ('0'+d.getDate()).substr(-2), + d = $e.datepicker('getDate'); + if (!d) return; + var day = ('0'+d.getDate()).substr(-2), month = ('0'+(d.getMonth()+1)).substr(-2), year = d.getFullYear(); $e.val(year+'-'+month+'-'+day); -- GitLab