Browse Source

Fixed DIV-226 allow future date for divorce effective date

pull/160/head
Charles Shin 8 years ago
parent
commit
4535c2f23d
4 changed files with 21 additions and 8 deletions
  1. +1
    -1
      edivorce/apps/core/static/js/ajax.js
  2. +7
    -3
      edivorce/apps/core/static/js/controllers.js
  3. +11
    -2
      edivorce/apps/core/static/js/main.js
  4. +2
    -2
      edivorce/apps/core/templates/question/09_other_questions.html

+ 1
- 1
edivorce/apps/core/static/js/ajax.js View File

@ -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);
}


+ 7
- 3
edivorce/apps/core/static/js/controllers.js View File

@ -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;
}
}


+ 11
- 2
edivorce/apps/core/static/js/main.js View File

@ -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,


+ 2
- 2
edivorce/apps/core/templates/question/09_other_questions.html View File

@ -86,8 +86,8 @@
<h2>Divorce is to take effect on:</h2>
<div class="radio"><label>{% input_field type="radio" class="radio-with-other" name="divorce_take_effect_on" value="the 31st day after" %}the 31st day after the date of this order</label></div>
<div class="radio"><label>{% input_field type="radio" class="radio-with-other" name="divorce_take_effect_on" value="specific date" %}a specific date
<span class="input-group date date-picker-group">
{% input_field type="text" name="divorce_take_effect_on_specific_date" id="effect_date" class="date-picker other-textbox input-inline form-control" tabindex="-1" placeholder="DD/MM/YYYY" %}
<span class="input-group date date-picker-group" data-allow-future-date="true">
{% input_field type="text" name="divorce_take_effect_on_specific_date" id="effect_date" class="date-picker-future other-textbox input-inline form-control" tabindex="-1" placeholder="DD/MM/YYYY" %}
<span class="input-group-addon" >
<i class="fa fa-calendar circle"></i>
</span>


Loading…
Cancel
Save