Skip to main content
Level 2
Apr 18, 2016 6:27 PM UTC
Solved

AEM forms and javascript

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. 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
radzmar
radzmarAccepted solution
Level 10
May 24, 2016 5:05 PM UTC

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();

4 replies

hitesh_m
Level 3
Apr 20, 2016 4:43 PM UTC

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. 

Translate
Level 2
Apr 22, 2016 8:42 PM UTC

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

Translate
radzmar
radzmarAccepted solution
Level 10
May 24, 2016 5:05 PM UTC

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();
Translate
hitesh_m
Level 3
May 24, 2016 5:57 PM UTC

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 !

Translate