diff --git a/edivorce/apps/core/static/js/ajax.js b/edivorce/apps/core/static/js/ajax.js index 76c85786..fe8c0b06 100644 --- a/edivorce/apps/core/static/js/ajax.js +++ b/edivorce/apps/core/static/js/ajax.js @@ -8,7 +8,7 @@ var ajaxOnChange = function () { var isValid = true; // Check if date is in valid format DD/MM/YYYY - if (el.is(".date-picker") || el.is(".date-pickers")){ + if (el.is(".date-picker") || el.is(".date-pickers") || el.is(".date-picker-future")){ isValid = validateDate(el); } diff --git a/edivorce/apps/core/static/js/controllers.js b/edivorce/apps/core/static/js/controllers.js index 8eb7c11f..a7459197 100644 --- a/edivorce/apps/core/static/js/controllers.js +++ b/edivorce/apps/core/static/js/controllers.js @@ -193,7 +193,8 @@ var validateDate = function(el){ return true; } - if (isValidDate(el.val())) { + var isFuture = el.is('.date-picker-future'); + if (isValidDate(el.val(), isFuture)) { el.val(formatDate(stringToDate(el.val()))); return true; } @@ -206,7 +207,7 @@ var validateDate = function(el){ }; // validates that a string is a valid date -var isValidDate = function(dateString) { +var isValidDate = function(dateString, isFuture) { if (dateString.trim() == '') { return true; } @@ -215,7 +216,10 @@ var isValidDate = function(dateString) { if (!isNaN(dt)) { var today = new Date(); - if (dt <= today && dt.getFullYear() > 1900) { + if (isFuture && dt >= today && dt.getFullYear() <= today.getFullYear() + 100) { + return true; + } + else if (!isFuture && dt <= today && dt.getFullYear() > 1900) { return true; } } diff --git a/edivorce/apps/core/static/js/main.js b/edivorce/apps/core/static/js/main.js index a61edd7c..90439714 100755 --- a/edivorce/apps/core/static/js/main.js +++ b/edivorce/apps/core/static/js/main.js @@ -117,10 +117,19 @@ var deleteAddedField = function(e){ // Configuration for datepicker var date_picker = function (selector, showOnFocus) { + var startDate, endDate; + if($(selector).data("allow-future-date")){ + startDate = "+1d"; + endDate = "+100y"; + } + else { + startDate = "-100y"; + endDate = "0d"; + } $(selector).datepicker({ format: "dd/mm/yyyy", - startDate: "-100y", - endDate: "0d", + startDate: startDate, + endDate: endDate, autoclose: true, todayHighlight: true, immediateUpdates: true, diff --git a/edivorce/apps/core/templates/question/09_other_questions.html b/edivorce/apps/core/templates/question/09_other_questions.html index 20a43916..87f960dd 100644 --- a/edivorce/apps/core/templates/question/09_other_questions.html +++ b/edivorce/apps/core/templates/question/09_other_questions.html @@ -86,8 +86,8 @@