1 Reply Latest reply on Apr 26, 2016 4:51 PM by erolst

    Script to check if input is numeric only

    miw

      I want to make a script to check if an input is numeric only.  The field is numeric but I do not want to validate as numeric only as the resultant Filemaker default dialog box is insufficient with the possible Yes and No result allowing an text override.  Using invalid(field) in the script works only if text only is input - but if someone were to enter "34g", it does not raise a warning for non-numeric input only.  An if statement with a range > 0 to also does not work as text is also ok.  I just want to test for input that is numeric only.  Seems like it should be simple but I can't figure out how...

        • 1. Re: Script to check if input is numeric only
          erolst

          So don't allow to override the validation – no more Yes and No, only Revert and Cancel.

           

          Besides that, I think

           

          isNumericOnly = ( Length ( GetAsNumber ( myNumber ) ) = Length ( myNumber ) )

           

          will tell you if a given literal is only numeric. (And yes, those extra parentheses are superfluous … )