Browse Source

REP-934 - Date formats

pull/160/head
Michael Olund 6 years ago
parent
commit
f982f9f2d8
2 changed files with 21 additions and 11 deletions
  1. +10
    -11
      edivorce/apps/core/static/js/ajax.js
  2. +11
    -0
      edivorce/apps/core/static/js/main.js

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

@ -5,17 +5,6 @@ var ajaxOnChange = function () {
// show/hide additional information if needed
reveal(el);
var isValid = true;
// Check if date is in valid format DD/MM/YYYY
if (el.is(".date-picker") || el.is(".date-pickers") || el.is(".date-picker-future")){
isValid = validateDate(el);
}
if (el.is("#email_textbox")){
isValid = validateEmail(el);
}
var skipAjax = el.attr('data-skip_ajax');
if (skipAjax !== undefined && skipAjax === "true") {
return;
@ -33,6 +22,16 @@ var ajaxOnChange = function () {
var question = el.prop('name');
var value = getValue(el, question);
var isValid = true;
// Check if date is in valid format DD/MM/YYYY
if (el.is(".date-picker") || el.is(".date-pickers") || el.is(".date-picker-future")){
isValid = validateDate(el);
}
if (el.is("#email_textbox")){
isValid = validateEmail(el);
}
// special behaviour for radio button with textbox
radioWithTextboxControl(el);


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

@ -836,6 +836,17 @@ var mirrorOnChange = function(e) {
if (e.which === 9) {
return;
}
// fix incorrect date formats / don't mirror invalid dates
if ($(this).is('.date-picker')) {
var isFuture = $(this).is('.date-picker-future');
if (isValidDate($(this).val(), isFuture) && $(this).val().trim().length) {
$(this).val(moment(stringToDate($(this).val())).format('MMM D, YYYY'));
} else {
return;
}
}
var target_select = $(this).attr("data-mirror_target");
var scale_factor_identifier = $(this).attr("data-mirror_scale");
var broadcast_change = $(this).attr("data-mirror_broadcast_change");


Loading…
Cancel
Save