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

SyamPrasanM
Tera Expert

Hi @Joe Taylor .

Hope this answere is useful to your question, use the client script  

 

Key Components:

  • Field Access: Uses g_form.getValue() to retrieve values from the short_description and description fields.
  • Regex Pattern:
    • var regex = /^[^a-z]{0,60}$/; checks for:
      • No lowercase letters ([^a-z]).
      • Length between 0 and 60 characters.

 

function onSubmit() {
// Get the values from the short_description and description fields
var shortDesc = g_form.getValue('short_description');
var desc = g_form.getValue('description');

// Define the regex pattern for 0-60 characters with no lowercase letters
var regex = /^[^a-z]{0,60}$/; // Allows any character except lowercase letters and restricts length

// Validate short_description field
if (!regex.test(shortDesc)) {
g_form.addErrorMessage("The Short Description must be between 0 and 60 characters and contain no lowercase letters.");
return false;
}

// Validate description field
if (!regex.test(desc)) {
g_form.addErrorMessage("The Description must be between 0 and 60 characters and contain no lowercase letters.");
return false; 
}

return true; 
}

Screenshot 2024-10-03 121456.png

 

 

 

 

 

 

 

Regards

Mule Syam Prasanna 

PRAVAL-LOGO.png

SyamPrasanM
Tera Expert

Hi @Joe Taylor .

Hope this answere is useful to your question, use the client script  

 

Key Components:

  • Field Access: Uses g_form.getValue() to retrieve values from the short_description and description fields.
  • Regex Pattern:
    • var regex = /^[^a-z]{0,60}$/; checks for:
      • No lowercase letters ([^a-z]).
      • Length between 0 and 60 characters.

 

function onSubmit() {
// Get the values from the short_description and description fields
var shortDesc = g_form.getValue('short_description');
var desc = g_form.getValue('description');

// Define the regex pattern for 0-60 characters with no lowercase letters
var regex = /^[^a-z]{0,60}$/; // Allows any character except lowercase letters and restricts length

// Validate short_description field
if (!regex.test(shortDesc)) {
g_form.addErrorMessage("The Short Description must be between 0 and 60 characters and contain no lowercase letters.");
return false;
}

// Validate description field
if (!regex.test(desc)) {
g_form.addErrorMessage("The Description must be between 0 and 60 characters and contain no lowercase letters.");
return false; 
}

return true; 
}

Screenshot 2024-10-03 121456.png

 

 

Regards

Mule Syam Prasanna 

PRAVAL-LOGO.png