Page 1 of 1

nuBeforeSave & return false

Posted: Thu Feb 19, 2015 3:56 pm
by alextouch
Hi

I added nuBeforeSave function in a form's JavaScript custom code like this:

Code: Select all

function nuBeforeSave(){
if(check()){
return true}
else{
alert('TOTAL IS 0 SO I CANNOT SAVE!');
return false}
}

function check(){
a=document.getElementById('total').value;
if(a!='0'){
return true}
else{
return false
}

function total(){
a=nuNumberise('a');
b=nuNumberise('b');
tot=a+b;
document.getElementById('total').value=tot;
}
And, in the 'a' and 'b' text object on the form, there is a JavaScript call to total() in onBlur field.

Now, if 'total' is 0 and I try to save, the alert appears and form isn't saved.
But if I try to change a or b value on the form, the function total() doesn't work.
It seems that after a "return false" in nuBeforeSave, all other JavaScript functions aren't work at all. I must reload form to get total() work properly.

Is there a way so that JavaScript functions on a form works even after a "return false" in nuBeforeSave?

Thank you
Alex