Custom input mask or data validation?

Is there a way to make a custom input mask for a control, or some way of data validation?  From what I've seen on iPad most of the input masks don't seem to really mask anything.  I've looked into using lua for validation but ran into a lot of dead ends trying to use pcall and assert.  Anyway was just wondering if there was a 'right' way to do data validation with app studio, or if that should just be left to the backend.

 

Thanks,

Seb

Have more questions? Submit a request

2 Comments

  • 0
    Avatar
    Sebastian.Woodland

    Ah, yes that's worked me before; sorry I didn't word this very well at all, I was trying to generalize the issue without getting into my specific problem and ended up missing the point... D'oh!  Anyway the problem I'm having is more with data TYPE validation, so for instance I have a field that needs to be a decimal number of some sort.  I don't really care about format or decimal places of the number, just that the control value is a number (although it would be ideal if there was an input mask that simply made it impossible for users to put in anything else). 

     The reason I brought up pcall and assert is I found some methods other people suggested like using the lua tonumber() function which should return false if the value is not a number, but it seems to just throw an error right away instead.  I wasn't sure if that was because PyXl is different in that regard or if it was just something I did wrong.

     

    Thanks,

    Seb

  • 0
    Avatar
    Sebastian.Woodland

    Here's a few screenshots of what I've seen with tonumber, I'm running this script on the OnChange of a field:

    if tonumber(thiscontrol:getValue()) == nil

    then inform("Nope") else inform("Yep") end

    When I put in 32 it thinks tonumber != nil, when I put in 2 it thinks tonumber = nil, and when i put in ) it just coughs up a lua error (number expected, got string) which makes no sense for a function that's supposed to convert a string to a number in the first place...

     

    It looks like the Money input mask works pretty well; I was worried at first because it still appeared to allow any value, but unlike integer or numeric it disabled them.  Nice!  It's not quite perfect for what I need because it still allows '$' and ','.  But it's definitely a huge improvement and should be good enough.

    Thanks!

    Seb

     

     




    Pyxample.PNG
    Pyxample2.PNG
    Pyxample3.PNG
Please sign in to leave a comment.
Powered by Zendesk