Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

AEM forms and javascript

Avatar

Level 2

Hi I m new to AEM forms, Please can you tell me how to create a basic form with two fields and a validate button. 

Requirnment : Validate button will check whether both fields left blank by using javascript. 

1 Accepted Solution

Avatar

Correct answer by
Level 10

Sorry, but this.value != "" isn't a good validation (see here on page 18).

You better use

this.rawValue !== null;

or the built-in method isNull() to check a fields value against null.

this.isNull();

View solution in original post

4 Replies

Avatar

Level 3

You can make your filed mandatory to avoid JS. 

Or

You can write your validation script under "Validate" expression. 

If you are using rule editor its quite simple. 

One sample validation is - 

this.value !==null   or this.isNull() for blank fields. Just write this script in validate expression. 

Avatar

Level 2

Many thanks Hitesh for the reply can you share a sample form. Then I can learn. (I m pretty new to AEM software) :D

Avatar

Correct answer by
Level 10

Sorry, but this.value != "" isn't a good validation (see here on page 18).

You better use

this.rawValue !== null;

or the built-in method isNull() to check a fields value against null.

this.isNull();

Avatar

Level 3

radzmar wrote...

Sorry, but this.value != "" isn't a good validation (see here on page 18).

You better use

  1. this.rawValue !== null;

or the built-in method isNull() to check a fields value against null.

 
  1. this.isNull();

 

 

Thanks. I updated the answer !