Forum Discussion

  • It is easy to create custom validation of your fields with script. The following application shows three different types of validation:

    (1) validation of a Brazilian Postal Code by pattern on individual keystrokes

    (2) Validation of a Brazilian Telephone Number by pattern on a field blur 

    (3) Validation of two Brazilian Real Currency fields on a form submission - Can you spot the validation rule I used? I thought it was a clever way to make bank and fund the Mas Que Nada QuickBase User Group Meeting in Brazil.

    Why U No Validate? - Add Record (yes you have permission)
    https://haversineconsulting.quickbase.com/db/bj43wedck?a=nwr

    Pastie Database
    https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=424

    Notes

    (1) You can validate anything with script using these and similar concepts including the Constraint Validation API included with HTML5.

    (2) There is a trick you need to use to activate the native input validation bubbles the browser support. Basically the validation bubbles will only show up when the form's submit button is clicked. Since QuickBase form's don't have a submit button you have to patch one in and hide it and proceed to QuickBase's form submission mechanism if your layer of validation did not produce and error

    (3) You can also validate fields that have one of the new HTML5 types such as number or email. However there is a trick you have to perform to change the type=text that QuickBase uses to one of the new types because the browser will not allow you to change the type attribute on an <input> (you have to use jQuery's $().replaceWith() method)

    (4) The attached graphic presents a hierarchy of validation layers - three in Userland and two under QuickBase's management. You need to use the idioms in this demo to insure your validation layer is evaluated before QuickBase starts its final validation process.

    (5) The example has a few small warts on it but the gist of the idea in working. If I get time I will update and refine the demo.

    (6) blah blah blah - Yeah I know I take a broad view of validation - basically validation is anything you do with the user's form prior to it being successfully submitted.

    (7) Will it blend (http://www.willitblend.com/)? - I mean will it embed?

    h t t p s://gist.github.com/dandiebolt/7dba391f831caa7d3175


    https://gist.github.com/dandiebolt/7dba391f831caa7d3175
  • CarlosCarlos's avatar
    CarlosCarlos
    Qrew Assistant Captain
    Dan, what do you mean by patching a submit button? tried this one out but no luck so far...
    • _anomDiebolt_'s avatar
      _anomDiebolt_
      Qrew Elite
      By "patching a submit button" I mean to interpose your own click handler which will trigger before QuickBase's click handler (if you allow it to happen). The relevant code that does the patching is highlighted below:
      var originalClickHandler = $("#saveButton")
       .data("events").click[0].handler;
      $("#saveButton").unbind("click");
      $("#saveButton").click(function() {
        var yours = parseFloat(_fid_9.value);
        var mine = parseFloat(_fid_10.value);
        if (yours > mine) {
          _fid_9.value = mine;
          _fid_10.value = yours;
        }
        originalClickHandler();
      });