Home > JSF > JSF Validation – restricting minimum and maximum length for a textarea

JSF Validation – restricting minimum and maximum length for a textarea

Restricting text length in textarea in JSF can be done as below.  Here we restrict the maximum length to be 390 and the minimum length to be 10. Please note that these restrictions will be applied only when the required attribute is true.

      <h:inputTextarea  required=”true” cols=”70″ rows=”9″ id=”message” value=”#{inviteaction.message}”>
          <f:validateLength maximum=”390″ minimum=”10″/>
    </h:inputTextarea>

where f and h namespaces are configured as 

  xmlns:h=”http://java.sun.com/jsf/html&#8221;
  xmlns:f=”http://java.sun.com/jsf/core&#8221;

Advertisements
Categories: JSF
  1. No comments yet.
  1. No trackbacks yet.

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

%d bloggers like this: