Need a regex to allow all characters and spaces, but no lower case letters. Valid length is 0 - 60.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2024 03:39 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 11:52 PM - edited 10-03-2024 10:19 PM
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.
- var regex = /^[^a-z]{0,60}$/; checks for:
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;
}
Regards
Mule Syam Prasanna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2024 05:11 AM
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.
- var regex = /^[^a-z]{0,60}$/; checks for:
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;
}
Regards
Mule Syam Prasanna