Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Validation Message Problem

Avatar

Former Community Member
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

Former Community Member
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

Former Community Member
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