JSF <f:validateLongRange> Tag

It is used to check whether the local value of a component is within a certain range or not. The value must be any numeric type or String that can be converted to a long.

# Attributes

Attribute Description
minimum It is used to set minimum length for the component.
maximum It is used to set maximum length for the component.

# Validating an input tag Example

// index.xhtml


<h:form id="user-form">
<h:outputLabel for="name">Provide Amount to Withdraw  </h:outputLabel><br/>
<h:inputText id="age" value="#{user.amount}" validatorMessage="You can Withdraw only between $100 and $5000">
<f:validateLongRange minimum="100" maximum="5000" />
</h:inputText><br/>
<h:commandButton value="OK" action="response.xhtml"></h:commandButton>
</h:form>

// User.java


import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class User{
int amount;
public int getAmount() {
return amount;
}
public void setAmount(int amount) {
this.amount = amount;
}
}

Output:

JSF F validatelongrange tag 1