- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2018 12:09 PM
I have two integer fields on a form and want an alert to show up if the sum of those two fields exceeds 6000. I am trying to do this with an onChange client script that looks like this:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var a = parseInt(g_form.getValue('field1'));
var b = parseInt(g_form.getValue('field2'));
if(a+b > 6000) {
alert('Total cannot exceed 6,000.');
}
}
What do I need to change in the above code in order for this to work? Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2018 12:38 PM
Hi davilu,
Please find below OnSubmit Client Script. It Working for me.
Code:
function onSubmit() {
//Type appropriate comment here, and begin script below
var strt = parseInt(g_form.getValue('a'));
var end =parseInt( g_form.getValue('b'));
var C = strt + end;
g_form.setValue('c',C);
if(C > 6000) {
alert('Total cannot exceed 6,000.');
return false;
}
else
return true;
}
Screenshot:
Thanks,
Bhojraj

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2018 12:22 PM
unless I am missing anything, your script looks fine to me. why don't you put some console.log statements in to check that you have good values for a and b.
console.log(a);
console.log(b);
and check your browser console for those results. are you getting good output there?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2018 12:38 PM
Hi davilu,
Please find below OnSubmit Client Script. It Working for me.
Code:
function onSubmit() {
//Type appropriate comment here, and begin script below
var strt = parseInt(g_form.getValue('a'));
var end =parseInt( g_form.getValue('b'));
var C = strt + end;
g_form.setValue('c',C);
if(C > 6000) {
alert('Total cannot exceed 6,000.');
return false;
}
else
return true;
}
Screenshot:
Thanks,
Bhojraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2018 12:53 PM
thanks raj! I used your code exactly and it still doesn't work. our team is working in a scoped environment, not sure if that matters at all...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2018 01:00 PM
Have you created OnSubmit client Script...?
can you check all variable that you are passed in the client script ?
Thanks,
Bhojraj