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

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

Postby cypherinfo » Mon Sep 18, 2017 4:18 am

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/index.php/Javascript_Functions#nuOnSave.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: 124
Joined: Fri Feb 19, 2010 2:12 am

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

Postby cypherinfo » Mon Sep 25, 2017 1:29 am

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.
cypherinfo
 
Posts: 124
Joined: Fri Feb 19, 2010 2:12 am

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

Postby mobilemcclintic » Wed Sep 27, 2017 7:14 am

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

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

Postby ellaspraggins » Wed Oct 04, 2017 6:11 pm

I would like to validate userform textbox entry for numbers only. I have code that works great for alphabet (letter) entry.
ellaspraggins
 
Posts: 1
Joined: Wed Oct 04, 2017 5:53 pm

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

Postby mobilemcclintic » Fri Oct 06, 2017 9:26 am

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();
mobilemcclintic
 
Posts: 54
Joined: Fri Oct 23, 2015 8:04 am


Return to General