Welcome to the nuBuilder forums!

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

[video] How to nuOnSave() for validating data to input

Post Reply
cypherinfo
Posts: 125
Joined: Thu Feb 18, 2010 5:42 pm
Contact:

[video] How to nuOnSave() for validating data to input

Unread post by cypherinfo »

Hello,
I need to check before to save a record if a field is not empty; the data to input in the field is mandatory.
I have read many posts and I have tried to use the JavaScript code in the wiki: nuOnSave() http://wiki.nubuilder.net/nubuilderv3/i ... Save.28.29

Code: Select all

function nuOnSave(){     
    var data = $('#title').val();     
    if(data != ""){ 
        return false;  
    }else{ 
        return true; 
    }
}
As you may see in this video: https://youtu.be/cS39GtXKOPE the record is saved even if the code should have stop it.
I wonder if I'm missing something. What may be an alternative to do the same validation?
Thank you.
cypherinfo
Posts: 125
Joined: Thu Feb 18, 2010 5:42 pm
Contact:

Re: [video] How to nuOnSave() for validating data to input

Unread post by cypherinfo »

Meantime I use this alternative code in the Before Save section of the Custom code of the form:

Code: Select all

if('#title#' == ''){
   nuDisplayError("Course title cannot be left blank..");
}
Hopefully, there will be a fix of that function.
mobilemcclintic
Posts: 54
Joined: Fri Oct 23, 2015 12:34 am

Re: [video] How to nuOnSave() for validating data to input

Unread post by mobilemcclintic »

Just out of curiosity, did setting Stop Blanks to Yes not work?
Attachments
Capture.PNG
Capture.PNG (13.64 KiB) Viewed 4608 times
mobilemcclintic
Posts: 54
Joined: Fri Oct 23, 2015 12:34 am

Re: [video] How to nuOnSave() for validating data to input

Unread post by mobilemcclintic »

I haven't tried it but I'd try using isNaN() as a check inside an if/then JavaScript function somewhere, either on an onchange event or in nuOnSave();
Post Reply