The variable 'group name' should accept only 'A to Z, a to z, 0 to 9 and _'

Archana23
Tera Contributor

The variable 'group name' should accept only 'A to Z, a to z, 0 to 9 and _' using client script, I have tried below script but it is not working as expected.

 

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


var pattern = new RegExp('^[a-zA-Z0-9,_]*$');


var result = pattern.test(newValue);


if(!result ){

alert('Input is invaild');


g_form.setValue("group_name", '');

}

1 ACCEPTED SOLUTION

Peter Bodelier
Giga Sage

Hi @Archana23,

 

No need to use a client script for this:

You can use the OOTB Regex validation:

PeterBodelier_3-1698073286624.png

 

PeterBodelier_2-1698073267010.png

 

PeterBodelier_1-1698073250151.png

 

PeterBodelier_0-1698073225098.png

 


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

View solution in original post

1 REPLY 1

Peter Bodelier
Giga Sage

Hi @Archana23,

 

No need to use a client script for this:

You can use the OOTB Regex validation:

PeterBodelier_3-1698073286624.png

 

PeterBodelier_2-1698073267010.png

 

PeterBodelier_1-1698073250151.png

 

PeterBodelier_0-1698073225098.png

 


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.