Browse Source

DIV-944: Added empty field check for adding child.

pull/160/head
Charles Shin 6 years ago
parent
commit
780bef6015
4 changed files with 55 additions and 3 deletions
  1. +1
    -1
      edivorce/apps/core/static/css/main.css
  2. +6
    -0
      edivorce/apps/core/static/css/main.scss
  3. +48
    -1
      edivorce/apps/core/static/js/main.js
  4. +0
    -1
      edivorce/apps/core/templates/question/06_children_your_children.html

+ 1
- 1
edivorce/apps/core/static/css/main.css
File diff suppressed because it is too large
View File


+ 6
- 0
edivorce/apps/core/static/css/main.scss View File

@ -1061,6 +1061,12 @@ textarea {
transition: 0.1s ease-in-out all;
}
&.hasError {
border: 1px solid #FF4136;
-webkit-transition: 0.1s ease-in-out all;
transition: 0.1s ease-in-out all;
}
h3 {
margin-top: 0;
}


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

@ -400,16 +400,63 @@ $(function () {
var returnToParent = function(options) {
$('.children-questions').hide();
$('.children-list').show();
clearQuestionWellError();
enableChildrenFooterNav({page:'review'});
saveChildQuestions(options);
populateChildrenFactSheets();
};
var scrollToFirstError = function() {
var hasErrors = $('.hasError');
if (hasErrors.length > 0) {
$('.hasError')[0].scrollIntoView();
}
};
var clearQuestionWellError = function() {
$('.children-questions .question-well').each(function () {
$(this).removeClass('hasError');
});
};
var checkNoEmptyField = function() {
var isNotEmpty = true;
$('.children-questions .question-well').each(function () {
var questionWell = $(this);
questionWell.removeClass('hasError');
questionWell.find('input').each(function (index, inputField) {
if (inputField.type === 'text') {
if (inputField.value === '') {
isNotEmpty = false;
questionWell.addClass('hasError');
} else if (inputField.id === 'childs_birth_date') {
if (!moment(inputField.value, "MMM D, YYYY").isValid()) {
isNotEmpty = false;
questionWell.addClass('hasError');
}
}
} else if (inputField.type === 'radio') {
if (questionWell.find('input:radio:checked').length === 0) {
isNotEmpty = false;
questionWell.addClass('hasError');
}
return false;
}
});
});
return isNotEmpty;
};
initializeChildRowControls($('body'));
$('#btn_save_child').on('click', function(e) {
e.preventDefault();
returnToParent({persist: true});
if (checkNoEmptyField() === true) {
returnToParent({persist: true});
} else {
scrollToFirstError();
}
});
$('#btn_save_child_return_later').on('click', function(e) {


+ 0
- 1
edivorce/apps/core/templates/question/06_children_your_children.html View File

@ -305,7 +305,6 @@
<div id="child_edit_buttons" class="form-buttons clearfix" hidden>
<a class="btn btn-primary" id="btn_revert_child" href="#"><i class="fa fa-arrow-circle-o-left"></i>&nbsp;&nbsp;&nbsp;Back</a>
<a class="btn btn-success pull-right" id="btn_save_child" name="claimant_children" href="#">Save changes&nbsp;&nbsp;&nbsp;<i class="fa fa-floppy-o"></i></a>
<a class="btn btn-primary pull-right id="btn_save_child_return_later save-spinner" id="btn_save_child_return_later" href="{% url 'overview' %}"><i class="fa fa-floppy-o"></i>&nbsp;&nbsp;&nbsp;Save and return later</a>
</div>
{% endblock %}


Loading…
Cancel
Save