Validation is very important part of any programming language, when we visit any website's registration form it says "This field is mandatory" or "Email id is not valid","Password doesn't match", these all are validations
What is a Validator-
A computer program or piece of code that checks syntax or value of any field according to a predefined condition is called Validator
Validators are used in every programming/scripting language.
How to Use Custom Validator in ADF Forms-
This is not complex to use validator in ADF forms, means in .jsff or in .jspx pages. Suppose we have a field of EmailId on form and we want to add custom email id validator on this field
To add validator in a field follow these steps
What is a Validator-
A computer program or piece of code that checks syntax or value of any field according to a predefined condition is called Validator
Validators are used in every programming/scripting language.
How to Use Custom Validator in ADF Forms-
This is not complex to use validator in ADF forms, means in .jsff or in .jspx pages. Suppose we have a field of EmailId on form and we want to add custom email id validator on this field
To add validator in a field follow these steps
- Select the field in Form
- Now go to property inspector and Select Validator,it is empty by default
- Now click on Validator edit in property inspector and create a validator in ManagedBean of taskflow
- It will look like this- Default Custom Validator
- Now we will add custom code to validate EmailId field in this validator
- if(object!=null){
- String expression="^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
- CharSequence inputStr=name;
- if(matcher.matches()){
- }
- else{
- throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,msg,null));
- }
- }
- }
- Now when we run this page, we can see validation