AEM 6.2 Touch UI Dialog Validation

In this article, I will walk you through a simple Touch UI dialog field validation.

The validation framework has changed for Touch UI. This uses Granite Foundation Validation framework to validate the dialog fields.


If a text field has more than 9 characters, the dialog should show an error.


Step 1: Create a Dialog and inside the dialog, create a textfield using a resource type. Add a “class” property to the text field node as shown below.



Step 2: Inside the component:

  • create a clientlibs folder (cq:ClientLibraryFolder) and add categories=”[cq.authoring.dialog]”
  • create a js folder and js.txt file inside clientlibs folder
  • Add a js (say validation.js) file inside js folder created #2.
  • Include the js file into js.txt file.

add below code to js.txt



Example Structure below:


Step 3: Add the Javascript logic into the js file created above:

Note that the selector is the class value we added in the first step 1. The validator identifies your field with the help of the class.

Thats it, when you open the dialog and add more than 9 characters into the field, it should give an error.


One thought on “AEM 6.2 Touch UI Dialog Validation

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s