Page 1 of 1

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

Posted: Sun Sep 17, 2017 8:48 pm
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.

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

Posted: Sun Sep 24, 2017 5:59 pm
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.

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

Posted: Tue Sep 26, 2017 11:44 pm
by mobilemcclintic
Just out of curiosity, did setting Stop Blanks to Yes not work?

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

Posted: Fri Oct 06, 2017 1:56 am
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();