Validation Regex For ONLY UPPERCASE combination of letters and or numbers without using script

ID NOBLE
Tera Expert

Hello,

 

Please I need a Regex Validation that only allows ALL CAPS combination of letters and or numbers in string fields without writing scripts

6 REPLIES 6

Isaac Vicentini
Mega Sage
Mega Sage

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.


Best regards,

Isaac Vicentini
MVP 2025


If my answer was helpful, mark it as Helpful or Accept as Solution.

@Isaac Vicentini #thank you for your response. Is this going to be Onchange Client Script OR Onload Client Script please?

@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.

 




Best regards,

Isaac Vicentini
MVP 2025


If my answer was helpful, mark it as Helpful or Accept as Solution.

@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.