servlets struts hibernate spring maven java
 

JSF <f:validateRegex> Tag



It is utilized to check whether the neighborhood estimation of a component is a match against an ordinary articulation from the java.util.regex bundle or not.

Tag Attributes

Attribute Description
pattern It is used to set a regular expression pattern for the component. It is a required attribute.

JSF <f:validateRegex> Tag Example

// index.xhtml

  1. <h:form id="form">  
  2. <h:outputLabel for="username">User Name</h:outputLabel>  
  3. <h:inputText id="name-id" value="#{user.name}" validatorMessage="Your name can have only Alphabets">  
  4. <f:validateRegex pattern="^([a-zA-Z]+(.)?[\s]*)$" />  
  5. </h:inputText><br/>  
  6. <h:commandButton value="OK" action="response.xhtml"></h:commandButton>  
  7. </h:form>  

// User.java

  1. import javax.faces.bean.ManagedBean;  
  2. import javax.faces.bean.RequestScoped;  
  3. @ManagedBean  
  4. @RequestScoped  
  5. public class User{  
  6. String name;  
  7. public String getName() {  
  8. return name;  
  9. }  
  10. public void setName(String name) {  
  11. this.name = name;  
  12. }  
  13. }  






© Javacodegeeks © 2019 - 2019
All Right Reserved and you agree to have read and accepted our term and condition.

Python 3