Forum Discussion

StephenRogers's avatar
StephenRogers
Qrew Trainee
8 years ago

QuickBase Scripting & Data Field Validation

I understand that there is ability to use ... is it Javascript? ...scripting in QBase to accomplish things that are not straight out of the UI.  

First question, is this Javascript or something else?

Second is, where is some info on how to use JS to add functionality.  I know JS but not how it fits into QBase.

Third is, the problem at hand for me is to do some field level numeric validation to eliminate common input errors in forms.  Is this the way to do it, with JS?  Or is there some other method.

I am an software engineer but just learning QBase for a customer project.  My searches aren't producing much in the way of "where do I start"?  All I really need is a pointer and example or two and I'm off to the races.

Thanks for any help!!!

Stephen

9 Replies

  • If you can give an example of the validation rules, there may be a simple way to create a formula which calculates if the data is valid.  Then you can have a form rule to block the save if the data is not valid.
  • For a numeric field, ability to limit to, say, a range between 91.5 and 94.8.
    Or integer between 0 and 99.
    Or...  etc.

    If you type in something wrong it either stops you or pops up an error.  Typical validation stuff.

    I know that some stuff like typing alpha characters into numeric is already handled.

    What's a formula...?  I'll go check that out in the user guide.
  • An example of a formula is a formula field called Valid? of type formula checkbox

    IF([entry field] >=91.5 and [entry field] <= 94.8,true, false)

    which is equialent to
    IF([entry field] >=91.5 and [entry field] <= 94.8,true)

    which is also equivalent to 

    [entry field] >=91.5 and [entry field] <= 94.8

    ie with a boolean you can make a statement and the system either says its true or called Bullshit on you and says its false.
  • Great - I'll look up formulas and give this a try!  Sounds promising.

    Thanks so much.
  • Dear Stephen, There is alternative to achieve this requirement using javascript.

    Please follow below steps.
    1. First Configure Dan's Image onload technique.
    2. https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=294&_ga=2.233694235.40686674...
    3. In your module.js code page ,  you can write javascript function as below to validate the character length in any numeric field. In field fid_147. if user enters digit more than or less than 6 then it will prompt error and clear the value from the same field.
    ---------------------------------------------------------------------------------------
    $('#_fid_147').focusout(function(){ 
    if ($('#_fid_147').val() != '' && $('#_fid_147').val().length != 6) { 
    alert('The PID should be 6 character');
    $('#_fid_147').val('');
    $('#_fid_147').focus();

    });
    ---------------------------------------------------------------------------------------
    $('#_fid_16').focusout(function(){ 
    if ($('#_fid_16').val() != '' && $('#_fid_16').val().length != 8) { 
    alert('The FW# should be 8 character');
    $('#_fid_16').val('');
    $('#_fid_16').focus();

    });
    ---------------------------------------------------------------------------------------
    I hope this will help you.

    Regards,
    Rahul