Validation Regex For ONLY UPPERCASE combination of letters and or numbers without using script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 12:52 PM - edited 09-30-2024 03:30 PM
Hello,
Please I need a Regex Validation that only allows ALL CAPS combination of letters and or numbers in string fields without writing scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 01:27 PM
Hi @ID NOBLE,
You can use this expression:
^[A-Z0-9]+$
Usage example:
// Define the regex for ALL CAPS letters and numbers
var regex = /^[A-Z0-9]+$/;
// Your String
var stringTest = "Regex VALIDATION";
// Perform validation
if (!regex.test(stringTest)) {
// Your code here
}
If my answer helped you in any way, please mark it as Helpful / Accept as Solution 🎯
Regards,
Isaac Vicentini.
MVP 2025 ✨
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 09:19 AM
@Isaac Vicentini #thank you for your response. Is this going to be Onchange Client Script OR Onload Client Script please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 09:24 AM - edited 10-01-2024 09:25 AM
@ID NOBLE, you can adapt it according to your needs, but it is generally used in onChange Client Script.
Usage example:
function onChange(control, oldValue, newValue, isLoading) {
// Skip validation if the form is loading
if (isLoading || newValue === '') {
return;
}
// Define the regex for ALL CAPS letters and numbers
var regex = /^[A-Z0-9]+$/;
// Perform validation
if (!regex.test(newValue)) {
// Show an error message
g_form.showFieldMsg('your_field_name', 'Only uppercase letters and numbers are allowed.', 'error');
g_form.clearValue('your_field_name'); // Optionally clear the field if invalid
} else {
// If valid, clear any existing error messages
g_form.hideFieldMsg('your_field_name', 'error');
}
}
If my answer helped you in any way, please mark it as Helpful / Accept as Solution 🎯
Regards,
Isaac Vicentini.
MVP 2025 ✨
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 12:45 PM
@Isaac Vicentini thank you so much. Although it works, but only that even with the error message displayed, I was still able to submit the form. Whenever an error message is displayed, users should not be able to submit their request unless the conditions specified are met. In this case, users are still able to submit the form without meeting the condition(s) in the script. Please the only thing left for the script is that users should not to be allowed to submit the form if they have not met the letters and numbers combination conditions.
Thank you.