diff --git a/src/main/resources/js/timesheet/table.js b/src/main/resources/js/timesheet/table.js index 84636d9..a4e2553 100644 --- a/src/main/resources/js/timesheet/table.js +++ b/src/main/resources/js/timesheet/table.js @@ -8,6 +8,8 @@ var savingError; var ppFlag; var dateRangeFlag; var dateFlag; +var timeStartFlag; +var timeEndFlag; var descrFlag; var pauseFlag; @@ -405,6 +407,14 @@ function prepareForm(entry, timesheetData, isModified) { form.saveButton.prop('disabled', false); }); + form.beginTimeField.change(function () { + form.saveButton.prop('disabled', false); + }); + + form.endTimeField.change(function () { + form.saveButton.prop('disabled', false); + }); + row.find('input.time.start, input.time.end') .timepicker({ showDuration: false, @@ -1120,17 +1130,41 @@ function submit(timesheetData, saveOptions, form, existingEntryID, if ((date == "") || (!isValidDate(validDateFormat))) { date = new Date().toJSON().slice(0, 10); } - + var beginTime = form.beginTimeField.timepicker('getTime'); if (beginTime === null) { - beginTime = new Date(); + if (timeStartFlag) + timeStartFlag.close(); + timeStartFlag = AJS.flag({ + type: 'warning', + title: 'Invalid start time format', + body: 'The start time should be a valid time.', + close: 'auto' + }); + + form.beginTimeField.css({ + "border-color": "red" + }); + return; } var endTime = form.endTimeField.timepicker('getTime'); if (endTime === null) { - endTime = new Date(); + if (timeStartFlag) + timeStartFlag.close(); + timeStartFlag = AJS.flag({ + type: 'warning', + title: 'Invalid end time format', + body: 'The end time should be a valid time.', + close: 'auto' + }); + + form.endTimeField.css({ + "border-color": "red" + }); + return; } date = date.replace(/-/g, "/");