Primefaces : How to set the max value for a inputTextarea component ?

You can use this function in Javascript :

onkeyup="if(this.value.length>(max value)){this.value=this.value.substring(0,5);alert('(Warning Text)')}"

Example :

<h:inputTextarea value="#{myController.bigtext}"
                 onkeyup="if(this.value.length>500){this.value=this.value.substring(0,5);alert('The maximum value is 500 characters')}"
                 styleClass="form-control"/>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s