Simple Javascript Validation without Alerts

Simple Javascript Validation without Alerts
In this article we are going to see simple Javascript form validations without using alerts.

We are going to validate the form fields and display the message near the text box.

We are going to have 4 fields in the html,
Username:  if this field is left empty an error message is shown near the textbox and when some value is entered in this field the message disappears

Email: This field should have ‘@’ to confirm it as email address, if not show an error message. If value is entered error message should disappear

Password: Should be greater than 6 characters if not show error message, on correct entry error message disappears

Pattern: This field will check for Regular Expression pattern. No special characters allowed in this field.




Read More

Custom Validators using JSF

Custom Validators using JSF
The custom validators are user-defined validators that are created to meet application-specific validation. (For Standard Validators check here)

Custom Validators can be created in 2 ways

  • Implementing Validator Interface
  • Use Bean Method

Example: Lets create a JSF page to check if the person is eligible to vote using custom validators

1. Create cvalidator java class and implement validator, write a function for validation
2. JSF Managed Bean
3. Register Custom validator class in faces-config.xml or using Annotations
4. Bind it with the UI component in JSF page

Implementing Validator Interface:
Create a java class and implement validator interface.

JSF Managed Bean –

Registering Custom Validator class:
This can be done in 2 ways,

  • Register in faces-config.xml
  • using Annotations




Bean Method:
JSF ManagedBean –














Read More