• Resolved benlashley80

    (@benlashley80)


    Hello, in my form i have Social security number, and when displayed after a page break on an html block, i want to hide some numbers with * like this: Social Sec # *****6678.

    if fieldname1 is Social Security #, and fieldname5 is HTML block. how can i accomplish this?

    thanks!

Viewing 15 replies - 1 through 15 (of 27 total)
  • Plugin Author CodePeople2

    (@codepeople2)

    Hello @benlashley80

    You can use a calculated field as an auxiliary (hiding it by ticking a checkbox in its settings) and display it on the second page instead of the original Social Security number.

    For example, if the original field is the fieldname1, the equation in the calculated field would be:

    '*'.repeat(String(fieldname1|r).length-4)+String(fieldname1|r).substr(-4)

    Best regards.

    Thread Starter benlashley80

    (@benlashley80)

    your knowledge is amazing my friend. recommending this plugin to all my website friends!

    Thread Starter benlashley80

    (@benlashley80)

    One more thing on this topic. How can I make sure they enter the required number of characters?

    SS must be 9 characters, how can prevent them from entering more or less characters?

    thanks!

    Plugin Author CodePeople2

    (@codepeople2)

    Hello @benlashley80

    If you are using a single line text control enter the number 9 and the min and max length attributes in its settings.

    Best regards.

    Thread Starter benlashley80

    (@benlashley80)

    I used a number field to prevent letter characters as SS number is digits only. why cant minimum and maximum length be controlled that way on number fields?

    can I force numbers only on single line text field? Thanks!

    Plugin Author CodePeople2

    (@codepeople2)

    Hello @benlashley80

    If you are using number fields, and the SS numbers cannot store by zero, you can limit the min and max values as 100000000 and maximum 999999999.

    Or you can use a single-line text field and validate it with regular expressions. You can enter the following regular expression through its settings:

    /^\d{9}$/

    Best regards.

    Thread Starter benlashley80

    (@benlashley80)

    I did try that with the SS#s on number field, but sadly yes, SS numbers can begin with 0, so this solution does not work. I will try the validate expression. thank you.

    Plugin Author CodePeople2

    (@codepeople2)

    Hello @benlashley80

    Note the plugin allows you to implement your own validation rules:

    https://cff.dwbooster.com/documentation#new-validation-rules

    Best regards.

    Thread Starter benlashley80

    (@benlashley80)

    i used the following code from your documentation.

    <SCRIPT>
    fbuilderjQuery(document).one('showHideDepEvent', function(){
    fbuilderjQuery
    .validator
    .addMethod(
    "zipcode",
    function(v,e)
    {
    return this.optional(e) || /^\d{5}([\-]?\d{4})?$/.test(v);
    }
    );
    fbuilderjQuery.validator.messages['zipcode'] = 'The zipcode is invalid';
    fbuilderjQuery('[id*="fieldname259_"]').addClass('zipcode');
    });
    </SCRIPT>

    but it does not return the error message “The zipcode is invalid”

    is there a way to make that message pop up?

    my form is here: https://votesplease.com/testvote/application/

    • This reply was modified 1 year, 2 months ago by benlashley80.
    Plugin Author CodePeople2

    (@codepeople2)

    Hello @benlashley80

    In your specific case, a better alternative is to use a single line text with regular expression. You can enter both the regular expression and error message directly in the field’s settings. It is weird using number field in your case because it display the error message “Please enter a value less than or equal to 100000000000000000.”

    However, if you prefer implementing your custom validation method, please use the formReady event:

    <script>
    fbuilderjQuery(document).on('formReady', function(){
    fbuilderjQuery
    .validator
    .addMethod(
    "zipcode",
    function(v,e)
    {
    return this.optional(e) || /^\d{5}([\-]?\d{4})?$/.test(v);
    }
    );
    fbuilderjQuery.validator.messages['zipcode'] = 'The zipcode is invalid';
    fbuilderjQuery('[id*="fieldname255_"]').addClass('zipcode');
    });
    </script>

    Best regards.

    Thread Starter benlashley80

    (@benlashley80)

    Im sorry, can you clarify this a a bit? I am using a single line text field for my zipcode. I put the expression /^\d{5}([-]?\d{4})?$/ in the field settings “validate against regular expression” and i have the html code in an html field:

    <script>
    fbuilderjQuery(document).one('showHideDepEvent', function(){
    fbuilderjQuery
    .validator
    .addMethod(
    "zipcode",
    function(v,e)
    {
    return this.optional(e) || /^\d{5}([\-]?\d{4})?$/.test(v);
    }
    );
    fbuilderjQuery.validator.messages['zipcode'] = 'The zipcode is invalid';
    fbuilderjQuery('[id*="fieldname277_"]').addClass('zipcode');
    });
    </script>

    Im not sure what you’re saying? but I do not get the error message. aslo i want to force numbers only.

    Plugin Author CodePeople2

    (@codepeople2)

    Hello @benlashley80

    If you use the regular expression, you don’t need the extra code in the “HTML Content” field.

    You need to enter the regular expression /^\d{5}\-?\d{4}$/ through the “Validate against a regular expression” attribute in the single text line field’s settings, and the error message through the “Error message when the regular expression fails” attribute.

    Please watch the following video:

    https://resources.developers4web.com/cff/tmp/2025/04/01/video-regular-expression_o.mp4

    Best regards.

    Thread Starter benlashley80

    (@benlashley80)

    what can I be done if the string can have variable lengths like 5 to 10 numbers, if the string is only 5 then *’.repeat(String(fieldname279|r).length-4)+String(fieldname279|r).substr(-4) would only cover 1 number. is there a variable I can add so that if the string is only 5, then do this: exampl: 12345 = ****5?

    Thread Starter benlashley80

    (@benlashley80)

    actually i just wrote this and it works

    if (String(fieldname279).length==5){
    '*'.repeat(String(fieldname279|r).length-1)+String(fieldname279|r).substr(-1)}
    else if (String(fieldname279).length==6){'*'.repeat(String(fieldname279|r).length-2)+String(fieldname279|r).substr(-2)}
    else if (String(fieldname279).length==7){'*'.repeat(String(fieldname279|r).length-3)+String(fieldname279|r).substr(-3)}
    else '*'.repeat(String(fieldname279|r).length-4)+String(fieldname279|r).substr(-4)
    Plugin Author CodePeople2

    (@codepeople2)

    Hello @benlashley80

    Mathematics is an excellent partner for tackling these types of tasks.

    You can implement the equation as follows:


    (function(){
    let v = String(fieldname279|r);
    let l = MAX(MIN(4, v.length-4), 0);
    return IF(l,'*'.repeat(v.length-l)+v.substr(-1*l), v);
    })()

    Best regards.

Viewing 15 replies - 1 through 15 (of 27 total)

The topic ‘replace numbers with special character’ is closed to new replies.