Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

AEM forms and javascript

Avatar

Avatar
Validate 1
Level 2
maleenf75325889
Level 2

Likes

3 likes

Total Posts

12 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
maleenf75325889
Level 2

Likes

3 likes

Total Posts

12 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
maleenf75325889
Level 2

18-04-2016

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. 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct Reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct Reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

24-05-2016

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

Answers (3)

Answers (3)

Avatar

Avatar
Validate 1
Level 2
hitesh_m
Level 2

Likes

3 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Validate 1
Level 2
hitesh_m
Level 2

Likes

3 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile
hitesh_m
Level 2

20-04-2016

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

Avatar
Validate 1
Level 2
hitesh_m
Level 2

Likes

3 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Validate 1
Level 2
hitesh_m
Level 2

Likes

3 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile
hitesh_m
Level 2

24-05-2016

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 !

Avatar

Avatar
Validate 1
Level 2
maleenf75325889
Level 2

Likes

3 likes

Total Posts

12 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
maleenf75325889
Level 2

Likes

3 likes

Total Posts

12 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
View profile
maleenf75325889
Level 2

22-04-2016

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