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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Validation Message Problem

Avatar

Not applicable
Hi



Let me describe my scenario briefly as follow:



1. I have no. of numeric fields (variable in count) available on my form. Lets name them as Weightages.

2. User enters values in those numeric fields (Weightages).

3. Before submitting the form, I want to validate whether the sum of all those numeric fields (Weightages) is equal to 100 or not.



What solution I implemented is that I pasted a hidden field on my form named as TotalCount. On the "PreSubmit" event of my form, I sum up all the Weightages and assign the total value to TotalCount (hidden field). On the "Validate" event of TotalCount (hidden field), I checked teh value of that field should be equal to 100 otherwise, Submit action should be cancelled.



The solution is working very fine. The only problem which I am facing is that I am getting the same validation error message two times.



So what is the solution to get that specific validation error message only once?



Thanks in advance.

synaqvi
2 Replies

Avatar

Level 10
Don't do it on presubmit ...do it on Calculate. If you do it that way you will not have to trigger the calculate it will happen as the fields are being filled out. Then put a validate script on the total field ensuring that it equals 100. When submit is pressed, the validat will fire and if a false is returned the submit will cancel itself.

Avatar

Not applicable
Dear Paul



I cannot script it in calculate event as the no. of weightages fields are variable (using tables). So every time I enter any value for any weightage field, system gives me validation error (for total field). But I want to see the error only once. Please advise.



Thanks in advance.

synaqvi