Restrict Variable Value to a Specific Format

MMT3
Tera Contributor

Is it possible to restrict a variable's value to look like this: RQ-12345678.  The user must always enter 'RQ-' and then 8 various numbers?  If so, what does the script look like?

 

Thank you!

1 ACCEPTED SOLUTION

SAI VENKATESH
Tera Sage
Tera Sage

Hi @MMT3 

You can try the following code :

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

    if (!newValue.match(/^RQ-\d{8}$/)) {
        alert("Invalid format. Please enter in the format RQ-12345678.");
		g_form.clearValue('description')
    }

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

 

Thanks and Regards

Sai Venkatesh

View solution in original post

2 REPLIES 2

SAI VENKATESH
Tera Sage
Tera Sage

Hi @MMT3 

You can try the following code :

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

    if (!newValue.match(/^RQ-\d{8}$/)) {
        alert("Invalid format. Please enter in the format RQ-12345678.");
		g_form.clearValue('description')
    }

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

 

Thanks and Regards

Sai Venkatesh

That worked perfectly!  Thank you!