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

Numberfield and textfield are required, but if they are empty, only numberfield shows error when submitting.

Avatar

Avatar
Level 1
dz_dai
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
dz_dai
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
View profile
dz_dai
Level 1

04-01-2021

My AEM version is 6.5. The nodes follow

 

<items jcr:primaryType="nt:unstructured">
   <number
       jcr:primaryType="nt:unstructured"                                     
       sling:resourceType="granite/ui/components/coral/foundation/form/numberfield"
       fieldLabel="number"
       min="1"
       name="./number"
       required="{Boolean}true"/>
   <text
       jcr:primaryType="nt:unstructured"
       sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
       fieldLabel="Text"
       name="./text"
       required="{Boolean}true"/>
</items>

 

 

Observe: (The numberfield and textfield are requiredIf these two fields are empty, and then click submit button, only numberfield shows error.

Then I fill numberfield, and click submit button, the text field shows error.

error1.png

error2.png

Expected: If the two fields are empty, both of them should show error when click submit button.

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

275 likes

Total Posts

320 posts

Correct Reply

87 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

275 likes

Total Posts

320 posts

Correct Reply

87 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
Anudeep_Garnepudi
MVP

06-01-2021

@dz_dai 

There is no such weightage or priority of fields based on types, all the form fields will be looped and validated on submit.

In your case, number field has an additional attribute "required" where textfield doesn't. Because of the required attribute, numberfield is being validated before the other fields(textfield) which is HTML validation. Try to inspect and remove the required attribute from numberfield, you see all fields turning red at once.

Screenshot 2021-01-06 at 1.39.39 PM.png

 

 

Answers (1)

Answers (1)

Avatar

Avatar
Seeker
MVP
Suraj_Kamdi
MVP

Likes

148 likes

Total Posts

159 posts

Correct Reply

42 solutions
Top badges earned
Seeker
Bedrock
Engage 1
Springboard
Validate 1
View profile

Avatar
Seeker
MVP
Suraj_Kamdi
MVP

Likes

148 likes

Total Posts

159 posts

Correct Reply

42 solutions
Top badges earned
Seeker
Bedrock
Engage 1
Springboard
Validate 1
View profile
Suraj_Kamdi
MVP

04-01-2021

@dz_dai 

Yeah, I have seen this kind of behavior earlier. Try to install any 6.5 feature or service pack.