Jump to content
  • 0

Data validation for calculations



3 answers to this question

Recommended Posts

  • 0


You can achieve this with a bit of JavaScript.


1) On your Submission Form DataPage, go to Configure Fields, add a Header & Footer.

2) Select the Footer, disable the HTML editor and paste the following:



document.addEventListener("BeforeFormSubmit", function(e){
var sum= parseInt(document.getElementById("InsertRecordFD_1").value) + parseInt(document.getElementById("InsertRecordFD_2").value) + parseInt(document.getElementById("InsertRecordFD_3").value);

 if(sum> 100)
alert("Sum of fields should not exceed 100");




How this works is you are prevented from submitting the entry if the sum of the three fields exceed 100.


Link to comment
Share on other sites

  • 0


May I know where are the results displayed?

I encountered this one before and I am using 4 fields (1 field for sum using Calculated Value element). Those fields are Number data type. I used a CASE WHEN function on my Calculated Value element. Here is the formula I used: 

CASE WHEN ([@field:X] + [@field:Y] + [@field:Z]) <= 100

THEN ([@field:X] + [@field:Y] + [@field:Z])




When the sum exceeds 100, the current value of sum will become 0. I always rely to this Caspio Function Reference when I need to review some functions: https://howto.caspio.com/function-reference/

Link to comment
Share on other sites

  • 0

Thanks to both of you for taking the time to address my question.  Futurist your script works the way I needed it to so thank you. 

trickson I hadn't heard of CASE WHEN before but now seeing what it can do you have helped me solve another problem I was having difficulty with.

Thanks to both of you again.


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...