Browse Source

Merge pull request #61 from dominikszopa/DIV-970

Add check for numbers in names
pull/160/head
Charles Shin 6 years ago
committed by GitHub
parent
commit
2b8e93bd5e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 96 additions and 32 deletions
  1. +1
    -1
      edivorce/apps/core/static/css/main.css
  2. +1
    -0
      edivorce/apps/core/static/css/main.scss
  3. +26
    -12
      edivorce/apps/core/static/js/ajax.js
  4. +22
    -0
      edivorce/apps/core/static/js/functions.js
  5. +10
    -2
      edivorce/apps/core/static/js/main.js
  6. +6
    -3
      edivorce/apps/core/templates/partials/alias_field.html
  7. +18
    -9
      edivorce/apps/core/templates/question/02_claimant.html
  8. +9
    -4
      edivorce/apps/core/templates/question/03_respondent.html
  9. +3
    -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


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

@ -1011,6 +1011,7 @@ textarea {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
width: 99%;
}
input.btn {


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

@ -5,6 +5,32 @@ var ajaxOnChange = function () {
// show/hide additional information if needed
reveal(el);
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);
}
if (el.is(".name")) {
isValid = validateName(el);
}
// All alias fields must be validated as they are treated as a response to the one question.
if (el.is(".alias-names")) {
var aliasFields = $('.alias-names');
aliasFields.each(function(){
isValid = validateName($(this));
return isValid;
});
}
var skipAjax = el.attr('data-skip_ajax');
if (skipAjax !== undefined && skipAjax === "true") {
return;
@ -20,18 +46,6 @@ 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);


+ 22
- 0
edivorce/apps/core/static/js/functions.js View File

@ -355,6 +355,28 @@ var validateEmail = function(el){
}
};
var validateName = function(el){
el.closest('.form-group')
.removeClass('has-error')
.find('span.help-block')
.remove();
var value = el.val();
var hasDigit = /\d/;
// check to make sure there are no digits in the string,
// because CEIS won't accept it
if (hasDigit.test(value)){
el.closest('.form-group')
.addClass('has-error')
.append('<span class="help-block">A name cannot have a number in it.</span>');
return false;
}
return true;
};
var $DateFormat = 'M d, yyyy';
var MomentFormat = 'MMM D, YYYY';


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

@ -22,7 +22,7 @@ $('input[type=number]').each(function() {
$(window).load(function(){
$('#questions_modal, #terms_modal').modal('show');
// Load child support act question text if child_suuport_in_order exist on the page and answered before.
// Load child support act question text if child_support_in_order exist on the page and answered before.
var childSupport = $('input[name="child_support_in_order"]:checked');
if (childSupport !== undefined) {
var wantChildSupport = childSupport.val() === 'NO' ? false : true;
@ -502,6 +502,8 @@ $(function () {
var checkNoEmptyField = function() {
var isNotEmpty = true;
var hasDigit = /\d/;
$('.children-questions .question-well').each(function () {
var questionWell = $(this);
questionWell.removeClass('hasError');
@ -515,7 +517,13 @@ $(function () {
isNotEmpty = false;
questionWell.addClass('hasError');
}
}
} else if (inputField.id === 'childs_name') {
// check for digits in the name
if (hasDigit.test(inputField.value)) {
isNotEmpty = false;
questionWell.addClass('hasError');
}
}
} else if (inputField.type === 'radio') {
if (questionWell.find('input:radio:checked').length === 0) {
isNotEmpty = false;


+ 6
- 3
edivorce/apps/core/templates/partials/alias_field.html View File

@ -8,8 +8,11 @@
<option value="with assumed name of" {% if alias_type == 'with assumed name of' %} selected {% endif %}>With assumed name of</option>
</select>
{% endcomment %}
<label>Also known as</label>
{% input_field type="text" name=name value=value multiple="true" class="form-control response-textbox" %}
<input type="button" class="btn btn-danger btn-delete-name form-control" value="Delete" />
<span class="form-group">
{% input_field type="text" name=name value=value multiple="true" class="form-control response-textbox alias-names" %}
</span>
<input type="button" class="btn btn-danger btn-delete-name form-control" value="Delete" />
</div>

+ 18
- 9
edivorce/apps/core/templates/question/02_claimant.html View File

@ -12,7 +12,9 @@
<div class="question-well">
<h3>Please enter your name (as it appears on your marriage certificate or registration of marriage)</h3>
{% input_field type="text" name="name_you" class="form-block input-wide response-textbox" %}
<span class="form-group">
{% input_field type="text" name="name_you" class="form-block input-wide response-textbox name" %}
</span>
<div class="collapse-trigger collapsed" data-toggle="collapse" aria-expanded="false" data-target="#collapse_changed_name" aria-controls="collapse_changed_name">
<div>
@ -77,12 +79,14 @@
{% include "partials/alias_field.html" with name="other_name_you" %}
</div>
<div id="other_names_fields">
{% if other_name_you %}
{% multiple_values_to_list source=other_name_you as values %}
{% for alias_type, value in values %} {% include "partials/alias_field.html" with name="other_name_you" alias_type=alias_type value=value delete_button="true" %} {% endfor %}
{% else %}
{% include "partials/alias_field.html" with name="other_name_you" %}
{% endif %}
{% if other_name_you %}
{% multiple_values_to_list source=other_name_you as values %}
{% for alias_type, value in values %} {% include "partials/alias_field.html" with name="other_name_you" alias_type=alias_type value=value delete_button="true" %} {% endfor %}
{% else %}
{% include "partials/alias_field.html" with name="other_name_you" %}
{% endif %}
</div>
<input type="button" id="btn_add_other_names" class="btn btn-success" value="Add name" data-add-for="you" />
<div id="other_name_warning_message"></div>
@ -91,12 +95,17 @@
<div class="question-well">
<h3>What was your last name when you were born?</h3>
<div>{% input_field type="text" name="last_name_born_you" class="form-block input-wide response-textbox" %}</div>
<span class="form-group">
<div>{% input_field type="text" name="last_name_born_you" class="form-block input-wide response-textbox name" %}</div>
</span>
<p>This is often referred to as Family name or Surname</p>
</div>
<div class="question-well">
<h3>What was your last name immediately before you were married?</h3> {% input_field type="text" name="last_name_before_married_you" class="form-block input-wide response-textbox" %}
<h3>What was your last name immediately before you were married?</h3>
<span class="form-group">
{% input_field type="text" name="last_name_before_married_you" class="form-block input-wide response-textbox name" %}
</span>
<p>This is often referred to as Family name or Surname</p>
</div>


+ 9
- 4
edivorce/apps/core/templates/question/03_respondent.html View File

@ -15,8 +15,9 @@
<div class="question-well">
<h3>What is your spouse's name ( enter name as it appears on the marriage certificate or registration of marriage)?</h3>
{% input_field type="text" name="name_spouse" class="form-block input-wide response-textbox" %}
<span class="form-group">
{% input_field type="text" name="name_spouse" class="form-block input-wide response-textbox name" %}
</span>
<div class="collapse-trigger collapsed" data-toggle="collapse" aria-expanded="false"
data-target="#collapse_legal_name" aria-controls="collapse_legal_name">
<div>
@ -106,13 +107,17 @@
<div class="question-well">
<h3>What was their last name when they were born?</h3>
{% input_field type="text" name="last_name_born_spouse" class="form-block input-wide response-textbox" %}
<span class="form-group">
{% input_field type="text" name="last_name_born_spouse" class="form-block input-wide response-textbox name" %}
</span>
<p>This is often referred to as Family name or Surname</p>
</div>
<div class="question-well">
<h3>What was their last name immediately before you were married?</h3>
{% input_field type="text" name="last_name_before_married_spouse" class="form-block input-wide response-textbox" %}
<span class="form-group">
{% input_field type="text" name="last_name_before_married_spouse" class="form-block input-wide response-textbox name" %}
</span>
<p>This is often referred to as Family name or Surname</p>
</div>


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

@ -94,7 +94,9 @@
<div class="question-well">
<h3>What is your child's name?</h3>
<p>Enter full name</p>
{% input_field type="text" name="child_name" class="form-block input-wide response-textbox children-input-block" placeholder="First, Middle, Last Name" data_mirror="true" data_mirror_target="#child_name_0" data_skip_ajax="true" %}
<span class="form-group">
{% input_field type="text" name="child_name" class="form-block input-wide response-textbox children-input-block name" id="childs_name" placeholder="First, Middle, Last Name" data_mirror="true" data_mirror_target="#child_name_0" data_skip_ajax="true" %}
</span>
</div>


Loading…
Cancel
Save