nuBeforeSave & return false

nuBeforeSave & return false

Postby alextouch » Fri Feb 20, 2015 12:26 am

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
alextouch
 
Posts: 27
Joined: Tue Jun 05, 2012 10:10 pm
Location: Bologna, Italy

Return to Custom Code



cron