Character limit on Virtual Agent User Input

Ryax1
Tera Guru

Hi all,

Does anyone know if there is a way of setting a character limit on user input fields in Virtual Agent topics? We have done similar things on variables in catalog items by using the max_length attribute however I can't see a way of doing this in VA. Despite educating our users we are finding that they write war and peace when we ask them to explain their issue "in a few words" so we wanted to limit the amount of text they could input for certain questions. It would also be useful for Mobile number fields so that we could limit it to 11 digits.

Any help would be greatly appreciated.

Kind Regards

Richard

1 ACCEPTED SOLUTION
11 REPLIES 11

StefanoZ
Mega Sage

You can try using Custom  Input format and use some code like this one to validate number of characters 

function validate(value) {
if (value && value.length <= 75) {
return true;
} else {
return false;
}
}

Hi StefanoZ,

Whilst I understand the code you have provided I have never been successful in using the Custom Input Controls before, is this something you have utilized? I'd love to know how I can make my own input that validates the numbers/characters. Would you mind sharing?

Thanks

Richard

Hi Stefanoz,

Thanks so much for making me aware of this; I've never noticed it before! It is much more efficient than the method I demonstrated in my response to Mary.
Your code worked perfectly however I ended up using this instead:

function validate(value) {
        var isValid = value.length <= 11

        return {
            valid: isValid,
            error: isValid ? undefined : "Sorry, mobile numbers should be no more than 11 digits'"
        };
}


Rich