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?
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.
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.