The CreatorCon Call for Content is officially open! Get started here.

Need a regex to allow all characters and spaces, but no lower case letters. Valid length is 0 - 60.

Joe Taylor
Giga Guru

Need a regex to allow all characters and spaces, but no lower case letters. Valid length is 0 - 60 characters.

 

I want to use this in a multiline variable called "item_short_description".

 

Thanks.

11 REPLIES 11

Hi @Joe Taylor in regex A-Z refers all characters between A to Z in all capital letters /s refers to spaces 0 to 60 allows upto 60 characters 

 

You can write a on change client script like below

function onChange(control, oldValue, newValue, isLoading) {

    if (isLoading || newValue == '') {

        return;

    }

 

 

    var pattern = /^[A-Z\s]{0,60}$/;

    if (!pattern.test(newValue)) {

  g_form.clearValue('variablename');

        g_form.showFieldMsg('variablename', 'Error message here ', 'error');

        

    

 

}

 

Regards
Harish

Thanks for the script.

 

But  I need all other characters:  !@#$%^&,   etc.

I was really hoping I could put in a NOT rules like [!a-z] and be done with it.

Hi @Joe Taylor got it you want to allow all special characters, in that case below script works. Kindly check.

    var pattern = /^[A-Z\s!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]{0,60}$/;

    if (!pattern.test(newValue)) {

       g_form.showFieldMsg('test', 'Error message here ', 'error');
    }
HarishKM_0-1710897353883.png

 

Negative Test:

HarishKM_1-1710897438162.png

 

Regards
Harish

Hi @Joe Taylor if your issue is resolved please accept the solution 🙂

Regards
Harish

Amit Pandey
Kilo Sage

Hi @Joe Taylor 

 

Can you try this-

^[A-Z\s\W_]{0,60}$

Regards,

Amit