I have the following bug in the code please if anyone have solution for it please suggest

sariksorte
Tera Contributor

I have a requirement that the value in #CPU should be more than 1 and less than 17 

I achieved that using regex but it is still showing below bug. How to fix this?

1 ACCEPTED SOLUTION

@sariksorte 

something like this should work

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue == '') {
        return;
    }

    g_form.hideFieldMsg('variableName');
    newValue = parseInt(newValue);
    var regex = /^(?:[2-9]|1[0-6])$/;
    if (!regex.test(newValue)) {
        g_form.showFieldMsg('variableName', 'Please enter a number between 2 and 16.', 'error');
        g_form.clearValue('variableName');
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

10 REPLIES 10

sariksorte
Tera Contributor

Thank you Ankur