I want to add validation on input text field in adf 12c .jsf page. When user is entering CNIC it should be in "xxxxx-xxxxxxx-x" this format, otherwise it will show error to input in correct format. Here is my input field code:
<af:inputText value="#{row.bindings.Name.inputValue}"
label="#{bindings.TblCertificationView1.hints.Name.label}"
required="#{bindings.TblCertificationView1.hints.Name.mandatory}"
columns="#{bindings.TblCertificationView1.hints.Name.displayWidth}"
maximumLength="#{bindings.TblCertificationView1.hints.Name.precision}"
shortDesc="#{bindings.TblCertificationView1.hints.Name.tooltip}" id="it2">
<f:validator binding="#{row.bindings.Name.validator}"/>
</af:inputText>
One way to do so is to use the validateRegex tag (https://www.javatpoint.com/jsf-validateregex).
It is used to check whether the local value of a component is a match against a regular expression from the java.util.regex package or not.
In your case :
<af:inputText value="#{row.bindings.Name.inputValue}"
label="#{bindings.TblCertificationView1.hints.Name.label}"
required="#{bindings.TblCertificationView1.hints.Name.mandatory}"
columns="#{bindings.TblCertificationView1.hints.Name.displayWidth}"
maximumLength="#{bindings.TblCertificationView1.hints.Name.precision}"
shortDesc="#{bindings.TblCertificationView1.hints.Name.tooltip}" id="it2">
<f:validator binding="#{row.bindings.Name.validator}"/>
<f:validateRegex pattern="(^[0-9]{5}-[0-9]{7}-[0-9]$)"/>
</af:inputText>