Skip to content

Commit

Permalink
188804152 script src error on broker registration form (#4958)
Browse files Browse the repository at this point in the history
* fix: add date validation for staff registration form

* fix: date validation for staff and agency roles in forms

* fix: add key value check for NPN input based on registry feature

* fix: add phone number validation for broker contact information
  • Loading branch information
bbodine1 committed Jan 28, 2025
1 parent 2a7dd39 commit c9fcb58
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 13 deletions.
49 changes: 46 additions & 3 deletions app/assets/javascripts/broker_role.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ $(document).on('turbolinks:load ajax:success', function () {
});

function brokerSearch() {

var broker_agency_search = document.getElementById(
'staff_agency_search'
).value;
Expand Down Expand Up @@ -114,10 +113,12 @@ function selectBrokereAgency(element) {
document.getElementById('broker-staff-btn').disabled = false;
}


/// components/benefit_sponsors/app/views/benefit_sponsors/profiles/registrations/new.html.erb
$(document).on('turbolinks:load ajax:success', function () {
validateForm();
checkDate();
checkKeyValue();
numKey();

$('#broker_agency_form').tabs({
activate: function (event, ui) {
Expand All @@ -131,6 +132,8 @@ $(document).on('turbolinks:load ajax:success', function () {
data: { profile_type: 'broker_agency_staff' },
success: function (data) {
$('#broker_agency_staff').html(data);
const dobInput = document.querySelector('#staff_dob');
checkDate();
indicateRequiredFields();
},
});
Expand Down Expand Up @@ -162,4 +165,44 @@ $(document).on('turbolinks:load ajax:success', function () {
}
},
});
});
});

function checkDate() {
const dobInput = document.querySelector(
'#staff_dob, #agency_staff_roles_attributes_0_dob'
);

if (dobInput) {
// Add event listeners
dobInput.addEventListener('blur', function () {
validDob(this);
});
}
}

function checkKeyValue() {
const npnInput = document.getElementById('inputNPN');

if (npnInput) {
npnInput.addEventListener('keypress', function (event) {
const isRegistryEnabled =
npnInput.dataset.enrollRegistryFeatureEnabled === 'true';

if (isRegistryEnabled) {
isAlphaNumeric(event);
} else {
isNumberKey(event);
}
});
}
}

function numKey() {
const phoneNum = $('[data-phone-number]');

if (phoneNum.data('phoneNumber') === true) {
phoneNum.on('keypress', function (event) {
isNumberKey(event);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
min: 110.years.ago,
max: 16.years.ago.beginning_of_month,
data: {input: "", invalid_dob_title: l10n('broker_agencies.invalid_dob_title'), invalid_dob_body: l10n('broker_agencies.invalid_dob_body'), invalid_dob_after: l10n("broker_agencies.invalid_dob_after", date: 16.years.ago.beginning_of_month.strftime('%m/%d/%Y')), invalid_dob_before: l10n("broker_agencies.invalid_dob_before", date: 110.years.ago.strftime('%m/%d/%Y'))},
required: true,
onblur: 'validDob(this)',
onkeydown: 'storeDateInput(event)'
required: true
%>
<div class="invalid-feedback">
<%= l10n("invalid_dob") %>
Expand All @@ -51,8 +49,8 @@
id: 'inputNPN',
class: 'form-control',
maxlength: '10',
onkeypress: EnrollRegistry.feature_enabled?(:allow_alphanumeric_npn) ? 'return isAlphaNumeric(event);' : 'return isNumberKey(event);',
disabled: npn_disabled
disabled: npn_disabled,
data: {enroll_registry_feature_enabled: EnrollRegistry.feature_enabled?(:allow_alphanumeric_npn) ? 'true' : 'false'}
%>
<div class="invalid-feedback">
<%= l10n('npn_error') %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
min: 110.years.ago,
max: 16.years.ago.beginning_of_month,
data: {input:"", invalid_dob_title: l10n('broker_agencies.invalid_dob_title'), invalid_dob_body: l10n('broker_agencies.invalid_dob_body'), invalid_dob_after: l10n("broker_agencies.invalid_dob_after", date: 16.years.ago.beginning_of_month.strftime('%m/%d/%Y')), invalid_dob_before: l10n("broker_agencies.invalid_dob_before", date: 110.years.ago.strftime('%m/%d/%Y'))},
required: true,
onblur: 'validDob(this)',
onkeydown: 'storeDateInput(event)'
required: true
%>
<div class="invalid-feedback">
<%= l10n("invalid_dob") %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
class: 'form-control phone_number',
minlength: '14',
maxlength: '14',
onkeypress: 'return isNumberKey(event)',
value: determine_phone_number(f.object),
data: { :"error-message" => phone_error }
data: { :"error-message" => phone_error, phone_number: true }
%>
<div class="invalid-feedback">
<%= phone_error %>
Expand Down

0 comments on commit c9fcb58

Please sign in to comment.