Masking a field

Nilson Lopes
Kilo Contributor

Hi everyone,

 

I am just starting out to learn about the platform and I need a bit of help. Can anyone tell me how to include a "/" as a mask of a field ?


Example: 

If an User inputs the number 20221111, I want to make it so that a non-admin user sees the field masked in the following way (2022/11111). 


Also, I want to make it so that while the User is typing the number, the "/" already shows up.

Also, the record must be saved in the table without the "/".

 

Can anyone help me in regards to what is the best way to do this. 

 

Thank you !

1 ACCEPTED SOLUTION

Vasantharajan N
Giga Sage
Giga Sage

Step 1: 

You can use the below onLoad client script to automatically add "/" after the user input the 4th character.

function onLoad() {
    //Type appropriate comment here, and begin script below
    g_form.getElement("<variable_name>").observe('input', function() {
        var cur = g_form.getValue("variable_name");
        if (cur.length == 4) {
            g_form.setValue("variable_name", cur + "/");
        }   
    });
}

 

Step 2: Use onSubmit client script to remove the "/" from the value or use BR to remove the value from the variable.


Thanks & Regards,
Vasanth

View solution in original post

3 REPLIES 3

Vasantharajan N
Giga Sage
Giga Sage

Step 1: 

You can use the below onLoad client script to automatically add "/" after the user input the 4th character.

function onLoad() {
    //Type appropriate comment here, and begin script below
    g_form.getElement("<variable_name>").observe('input', function() {
        var cur = g_form.getValue("variable_name");
        if (cur.length == 4) {
            g_form.setValue("variable_name", cur + "/");
        }   
    });
}

 

Step 2: Use onSubmit client script to remove the "/" from the value or use BR to remove the value from the variable.


Thanks & Regards,
Vasanth

Here goes the onSubmit Client Script to remove the' / ' (step 2):

function onSubmit() {

   //Type appropriate comment here, and begin script below


   var noBar = g_form.getValue('variable_name').replace(/\D/g,'');
   g_form.setValue('variable_name',noBar);
}

Hi Vasantharajan N,

 

I have below requirements from customer.

In Incident form if the end user updated personal information in the work notes section like Passport number or DL number (EX: DL1234567) I need to hide "1234567" from 1234567 to ####### using background script only can you please help me.

PREVIEW