EGL Development User Group

EGL Development User Group

EGL Development User Group

The EGL Development User Group is dedicated to sharing news, knowledge, and insights regarding the EGL language and Business Developer product. Consisting of IBMers, HCL, and users, this community collaborates to advance the EGL ecosystem.

 View Only
  • 1.  validate numeric input

    Posted Wed April 15, 2015 08:02 AM

    Hello, I am trying to validate if input of DojoTextField is numeric or not but I don' t get the correct result. If it has 9 digits and if it is a number is valid.

    My code below: 

     
    private function myValidator (input string in, constraints dictionary in) returns(string?)           if(strlib.characterLen(input) == 0 || strlib.characterLen(input) < 10)                  return (null);             else                  return ("Input has more than 9 digits");             end             if (input matches "[0-9]")           else              return ("Not a number");                   end             return;  end

     

     

    michaeldefox


  • 2.  Re: validate numeric input

    Posted Wed April 15, 2015 09:40 AM

    Hi Michael
    Try this:

    If (DojoTextField is numeric)
       if (DojoTextField > 999999999)
         return("Invalid");
       end
    else
       return("Invalid");
    end
     

    Best regards
    Peter Vilhelmsen, Xact

    PVIL


  • 3.  Re: validate numeric input

    Posted Thu April 16, 2015 02:00 AM

    Hi Michael,

    You could give this snippet a try. This validator only accepts positive integers. You would have to alter constant inputmask if you have other needs (like accepting negative integers, decimals etc.).

    private function myValidator (input string in, constraints dictionary in) returns(string?)   error string?;   const inputmask string = "[0-9]+";   case      when (!DojoLib.VALIDATORS.PatternValidator(input, inputMask))         error = "Invalid number";        when (strlib.characterLen(input) > 10)           error = "Input has more than 9 digits";     end   return (error);  end

     

    Regards,

    Guus

    gweis