The variable should not allow any Uppercase characters

Community Alums
Not applicable

Hi,

I have a variable Description. The requirement is to NOT allow for any UPPERCASE letters.  Auto adjust to all lowercase please. Also the requirement is to not allow more than 18 characters. 18 characters part is done though. Kindly help.

 

change.PNG

 

 

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

    

    var contains_space = "";
    var more_chars = "";
    var regex = new RegExp("^[a-zA-Z0-9]*$");


    if (newValue.length > 18) {
        alert("More than 18 chacters entered.");
        g_form.setValue('description', " ");

    } else if (!regex.test(newValue)) {
        var no_space = newValue.replace(" ", "_");
        g_form.setValue('description', no_space);
        //  g_form.setValue('topic', no_space);
        contains_space = "true";
	}
}

 

  

Regards

Suman P.

1 ACCEPTED SOLUTION

AnveshKumar M
Tera Sage
Tera Sage

Hi @Community Alums 

If you want to convert all characters to lower case automatically, try the following script in your onChange.

 

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

    

    var contains_space = "";
    var more_chars = "";
    var regex = new RegExp("^[a-zA-Z0-9]*$");


    if (newValue.length > 18) {
        alert("More than 18 chacters entered.");
        g_form.setValue('description', " ");

    } else if (!regex.test(newValue)) {
        var no_space = newValue.replaceAll(" ", "_");
        g_form.setValue('description', no_space.toLowerCase());
        //  g_form.setValue('topic', no_space);
        contains_space = "true";
	} else {
        g_form.setValue('description', newValue.toLowerCase());
	}


}

 

Please mark my answer helpful and accept as a solution if it helped 👍✔️

Thanks,
Anvesh

View solution in original post

2 REPLIES 2

AnveshKumar M
Tera Sage
Tera Sage

Hi @Community Alums 

If you want to convert all characters to lower case automatically, try the following script in your onChange.

 

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

    

    var contains_space = "";
    var more_chars = "";
    var regex = new RegExp("^[a-zA-Z0-9]*$");


    if (newValue.length > 18) {
        alert("More than 18 chacters entered.");
        g_form.setValue('description', " ");

    } else if (!regex.test(newValue)) {
        var no_space = newValue.replaceAll(" ", "_");
        g_form.setValue('description', no_space.toLowerCase());
        //  g_form.setValue('topic', no_space);
        contains_space = "true";
	} else {
        g_form.setValue('description', newValue.toLowerCase());
	}


}

 

Please mark my answer helpful and accept as a solution if it helped 👍✔️

Thanks,
Anvesh

Hi Anvesh, can we add multiple variables in one on change to restrict to convert to lower case