fixed the fucking SSN LETS GOOOOO!!!!

This commit is contained in:
Ben 2024-01-17 02:46:53 -06:00
parent 796bb09b38
commit d5e588a0fe
1 changed files with 18 additions and 1 deletions

View File

@ -120,7 +120,24 @@
<%# This is for Social Security formatting and # of digits %>
<%# This is for Social Security formatting and # of digits %>
<script>
document.addEventListener('DOMContentLoaded', () => {
const ssnField = document.getElementById('ssn-field');
ssnField.addEventListener('input', () => {
let ssn = ssnField.value.split('-').join(''); // Remove dashes
ssn = ssn.replace(/\D/g, ''); // Keep numbers only
if (ssn.length > 3 && ssn.length <= 5) {
ssn = ssn.slice(0, 3) + '-' + ssn.slice(3);
} else if (ssn.length > 5) {
ssn = ssn.slice(0, 3) + '-' + ssn.slice(3, 5) + '-' + ssn.slice(5, 9);
}
ssnField.value = ssn; // Update the field value
});
});
</script>