Maxlength

Vaishali 11
Tera Guru

I have a table string field where I want to set a maxlength of 240 characters. I have done that using the dictionary entry, but I also want to show an error message if it exceeds 240 characters. I have written an onchange client script with showfieldmsg error, but it's not working.

Any suggestions for this?

1 ACCEPTED SOLUTION

The line.length will never exceed 240 chars because the limit is 240 chars.

So its not a valid if statement.

Maybe change the line.length > 240 to line.length == 240

and then   g_form.showFieldMsg('line_description''Line description cannot not exceed 240 characters.''error'); or something like that

View solution in original post

3 REPLIES 3

Sandeep Rajput
Tera Patron
Tera Patron

@Vaishali 11 Could you please post your script here.

@Sandeep Rajput , please find the script below, written on onchange of the field

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var line = g_form.getValue('line_description');
    if (line.length!="" && line.length > 240) {
        g_form.showFieldMsg('line_description''Line description should not exceed 240 characters.''error');
   
    }

    //Type appropriate comment here, and begin script below

}

The line.length will never exceed 240 chars because the limit is 240 chars.

So its not a valid if statement.

Maybe change the line.length > 240 to line.length == 240

and then   g_form.showFieldMsg('line_description''Line description cannot not exceed 240 characters.''error'); or something like that