diff --git a/edivorce/apps/core/static/js/main.js b/edivorce/apps/core/static/js/main.js index 66519588..81b2c9b1 100755 --- a/edivorce/apps/core/static/js/main.js +++ b/edivorce/apps/core/static/js/main.js @@ -61,16 +61,26 @@ $(function () { } // Add name button adds new input field for adding other name - // Maximum of two other name fields allowed + // Maximum of two other name fields allowed $("#btn_add_other_names").on('click', function () { if ($('#other_names_fields input[type=text]').length < 2) { $('#other_names_fields').append($('#other_names_group').children().clone(true)); } - else { - $('#btn_add_other_names').prop("disabled",true).prop("value","Max 2 other names"); - } + + showWarningOtherName(); }); + // Show warning text when there are 2 other name fields + var showWarningOtherName = function() { + if ($('#other_names_fields input[type=text]').length >= 2) { + $('#btn_add_other_names').hide(); + $('#other_name_warning_message').html("

Max 2 other names, please enter only the name variations to be shown on the order from the court

"); + } + }; + + // show warning message if other name field is already at its maximum number when the page rendered + showWarningOtherName(); + $("#btn_add_reconciliation_periods").on('click', function () { $('#reconciliation_period_fields').append($('#reconciliation_period_group').children().clone()); // add event lister for newly added from_date field, to_date field, delete button, and date picker @@ -164,7 +174,8 @@ var deleteAddedField = function(e){ //enable btn_add_other_names button if (button.prop('id') == "btn_add_other_names"){ - button.prop('disabled',false).prop('value','Add name'); + button.show(); + $('#other_name_warning_message').html(""); } // when there is only one field left, clear it instead of delete it diff --git a/edivorce/apps/core/templates/question/02_claimant.html b/edivorce/apps/core/templates/question/02_claimant.html index 9d151739..685ab487 100644 --- a/edivorce/apps/core/templates/question/02_claimant.html +++ b/edivorce/apps/core/templates/question/02_claimant.html @@ -85,6 +85,7 @@ {% endif %} +