You are viewing limited content. For full access, please sign in.

Question

Question

Is there a jquery that can remove any non numeric character in a single-line field after a lookup rule

asked on January 26

Is there a jquery that can remove any non numeric character in a single-line field after a lookup rule?  i've tried googling and came up with this, however, it doesnt seem to remove any non-numeric characters.

// Wait until the form is fully loaded
$(document).ready(function () {
    // Replace 'Field123' with your actual field ID from the Forms designer
    var $field = $('.ssn input');

    // Listen for input changes in real time
    $field.on('input', function () {
        var originalValue = $(this).val();
        // Remove all non-numeric characters
        var numericValue = originalValue.replace(/[^0-9]/g, '');
        // Update the field only if it changed
        if (originalValue !== numericValue) {
            $(this).val(numericValue);
        }
    });
});
 

0 0

Answer

SELECTED ANSWER
replied on January 26

Can you try changing 

$field.on('input', function () {

to 

$field.on('change', function () {

 

1 0

Replies

replied on January 26

Which form designer are you using?

0 0
replied on January 26

LF forms 10.4

0 0
SELECTED ANSWER
replied on January 26

Can you try changing 

$field.on('input', function () {

to 

$field.on('change', function () {

 

1 0
replied on January 27

it worked.  i'm not sure why i was doing this but i was putting an extra (.) before the "change"--- no wonder it didn't work.  now it's working perfectly.

incorrect: $field.on('.change', function () {

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.