Hi, I am trying to find a way for the validator not to allow more than 100 in total, but allow less.
I checked this code from mvanepps and this code from ahmedA but I can't make it work. I am not allowed to click on next without the error.
Any clue please?
Thanks
You will need to take every value and store it in a variable as total, if this total is gt 100 then throw an error. It should look something like below.
var a=document.getElementById('QR~QID82#1~1~1~TEXT').value;
var b=document.getElementById('QR~QID82#1~2~1~TEXT').value;
total=a+b;
if(total>100)
{
//Throw error js
}
Thanks grahulp5 but I don't really know what to do with that... :(
You will need to get the values using above js or you can get js for the same online, then store it in a new variable as total like below,
var total=a+b+...
where a, b are the initial variables where your data is stored.
here is an example:
https://stackoverflow.com/questions/6412376/jquery-calculate-the-sum-and-total-of-products
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.