Auto convert upper case to lower case

Community Alums
Not applicable

Hi,

I am trying to auto convert upper case to lower case. I wrote the code, but it is not working. Please let me know the mistake. Kindly help.

 

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

    var new_Schema = g_form.getValue("new_schema_name");
	newValue = new_Schema.toString().toLowerCase();
    var len_Schema = new_Schema.length;
    if (len_Schema > 15) {
        g_form.addErrorMessage("The maximum characters entered can be 15");
		g_form.clearValue("new_schema_name");
    }


}

 

autoConvert.PNG

 

Regards

Suman P.

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi @Community Alums 

I don't believe you can set "newValue" to what you're trying to do and should instead, declare a new JavaScript variable and set that with your lowercase script. Additionally, per your code, you're not actually doing anything with it, so I'm unsure what you mean by it's not working. Per your code, you're checking character count and that has nothing to do with lowercase, etc.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

3 REPLIES 3

Allen Andreas
Administrator
Administrator

Hi @Community Alums 

I don't believe you can set "newValue" to what you're trying to do and should instead, declare a new JavaScript variable and set that with your lowercase script. Additionally, per your code, you're not actually doing anything with it, so I'm unsure what you mean by it's not working. Per your code, you're checking character count and that has nothing to do with lowercase, etc.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Community Alums
Not applicable

Thank you @Allen Andreas ,

I finally realized my mistake.

 

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

    var new_Schema = g_form.getValue("new_schema_name");
    var len_Schema = new_Schema.length;
    if (len_Schema > 15) {
        g_form.addErrorMessage("The maximum characters entered can be 15");
        g_form.clearValue("new_schema_name");
    }
    g_form.setValue("new_schema_name", new_Schema.toString().toLowerCase("new_schema_name"));

}

 

Regards

Suman P.

Hi,

Glad you got it resolved and are now leveraging the actual lowerCase part of your script!

If my reply above helped guide you Correctly, please consider marking it as "Accept Solution".

Thanks and take care! 😀


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!