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

Avatar

Avatar

dz_dai

Avatar

dz_dai

dz_dai

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

Anudeep_Garnepudi

MVP

Avatar

Anudeep_Garnepudi

MVP

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

Suraj_Kamdi

MVP

Avatar

Suraj_Kamdi

MVP

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.