How to limit textarea input length

One frequent questions I get is how to limit the number of characters that a user is allowed to enter into a textarea control.

The html textarea control does not support a maxlength property. You can google this same question and find answers on how enforce maxlength for textareas using client side scripting. However in frevvo it’s very easy using a business rule.

Imagine our form contains a textarea input called Description that we want to limit to 500 characters. If the user enters > 500 we want the form to indicate the error and tell the user how many characters they are over the limit. And most important we don’t want to allow them to submit the form until they correct the description to be < 500 characters.

This simple business rule does this for a textarea control named ‘D’. See the frevvobusiness rules documentation for details. Try a sample form here
if (D.value.length > 500) {
D.valid = false;
D.status = 'Invalid. Max 500 chars allowed and you have entered: ' + D.value.length;
} else {
D.valid = true;
}

Html does support the maxlength property for other control types and the browsers respect this by preventing entry of more characters then the specified maxlength. frevvo support maxlength for non textarea controls via the Max Length property in the form designer.