Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

nuBeforeSave & return false

alextouch
Posts: 38
Joined: Tue Jun 05, 2012 2:40 pm
Location: Bologna, Italy
Contact:

nuBeforeSave & return false

Unread post 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
Post Reply