Regex to validate 'GITO_ESA_TC_090' format

Ankita9793
Tera Contributor

Hi All,

 

Can someone please help me with Regex to validate below format.  Field should basically accept only below format. 

GITO_ESA_TC_090 

1 ACCEPTED SOLUTION

Mark Manders
Mega Patron
function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === '') {
        return;
    }

    var pattern = /^GITO_ESA_TC_\d{3}$/;
    
    if (!pattern.test(newValue)) {
        g_form.showFieldMsg('your_field_name', 'Invalid format. Please use the format: GITO_ESA_TC_###', 'error');
    } else {
        g_form.hideFieldMsg('your_field_name');
    }
}

Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

View solution in original post

2 REPLIES 2

Sandeep Rajput
Tera Patron
Tera Patron

@Ankita9793 Please try this Regex.

/^[A-Z]{4}_[A-Z]{3}_[A-Z]{2}_[0-9]{3}$/gm

 

Hope this helps.

Mark Manders
Mega Patron
function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === '') {
        return;
    }

    var pattern = /^GITO_ESA_TC_\d{3}$/;
    
    if (!pattern.test(newValue)) {
        g_form.showFieldMsg('your_field_name', 'Invalid format. Please use the format: GITO_ESA_TC_###', 'error');
    } else {
        g_form.hideFieldMsg('your_field_name');
    }
}

Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark