Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issue #15195: Expiration date can be set before start date (#2551)
Co-authored-by: encuestabizdevgit <devgit@encuesta.biz>
- Loading branch information
1 parent
cb1ba58
commit 53008de
Showing
5 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Validate settings form depending on form name | ||
*/ | ||
function validateSettingsForm($form) { | ||
switch ($form.attr('id')) { | ||
case 'publication': | ||
return validateEndDateHigherThanStart( | ||
$('#startdate_datetimepicker').data('DateTimePicker'), | ||
$('#expires_datetimepicker').data('DateTimePicker'), | ||
expirationLowerThanStartError | ||
); | ||
default: | ||
return true; | ||
} | ||
} | ||
|
||
/** | ||
* Validates that an end date is not lower than a start date | ||
*/ | ||
function validateEndDateHigherThanStart(startDatePicker, endDatePicker, errorMessage) { | ||
if (!startDatePicker || !startDatePicker.date()) { | ||
return true; | ||
} | ||
if (!endDatePicker || !endDatePicker.date()) { | ||
return true; | ||
} | ||
const difference = endDatePicker.date().diff(startDatePicker.date()); | ||
if (difference >= 0) { | ||
return true; | ||
} | ||
LS.LsGlobalNotifier.create(errorMessage, 'well-lg bg-danger'); | ||
return false; | ||
} |