limit characters of multiline text

Vinya Jakkula
Tera Contributor
Hi Team,
can anyone please help me.Below script is working in native UI. When user typing itself, it will stop if user entered more than the characters mentioned in script.i required the same way work in portal.
 
function onLoad() {
    var control = g_form.getControl('comments');
    //Set its onkeyup method
    control.onkeyup = isMaxLength;

}


function isMaxLength() {
    var mLength = 170;
    var control = g_form.getControl('comments');
    if (control.value.length > mLength) {
        g_form.hideErrorBox('comments');
        g_form.showErrorBox('comments', 'You have reached the maximum character limit for this field.');
        control.value = control.value.substring(0, mLength);
    } else {
        g_form.hideErrorBox('comments');
    }
}
6 REPLIES 6