How to limit characters on a field type masked?

Julie Catano
Kilo Guru

I'm looking for the best way to limit characters for a masked variable field.

 

Currently I'm using field type "masked" so it will be encrypted.  I need to limit the below field characters.

 

1.  User ID (limit 8 characters, both alphabetical and numeral)

2.  Pin# (limit 4 numeral characters)

 

Any help would be greatly appreciated.

1 ACCEPTED SOLUTION

SAI VENKATESH
Tera Sage
Tera Sage

Hi @Julie Catano 

You can try the below code 

1: USERID

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

    if (!newValue.match(/^[A-Za-z0-9]{0,8}$/)) {
        alert("You need to enter 8 characters in USERID");
		g_form.clearValue('userID')
    }

   //Type appropriate comment here, and begin script below
   
}

2: pin

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

    if (!newValue.match(/^\d{0,4}$/)) {
        alert("You need to enter 4 digits in PIN);
		g_form.clearValue('pin')
    }

   //Type appropriate comment here, and begin script below
   
}

 

Thanks and Regards

Sai Venkatesh

 

View solution in original post

1 REPLY 1

SAI VENKATESH
Tera Sage
Tera Sage

Hi @Julie Catano 

You can try the below code 

1: USERID

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

    if (!newValue.match(/^[A-Za-z0-9]{0,8}$/)) {
        alert("You need to enter 8 characters in USERID");
		g_form.clearValue('userID')
    }

   //Type appropriate comment here, and begin script below
   
}

2: pin

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

    if (!newValue.match(/^\d{0,4}$/)) {
        alert("You need to enter 4 digits in PIN);
		g_form.clearValue('pin')
    }

   //Type appropriate comment here, and begin script below
   
}

 

Thanks and Regards

Sai Venkatesh