1 Reply Latest reply: Mar 20, 2013 12:10 PM by InoL RSS

    Regular Expression

      The user should enter exactly 4 digits.
      I created an item text ,*number*,*maximum length*=4

      I created this function:
      FUNCTION numeric (v in varchar2)RETURN boolean IS
      return regexp_like(v,'\d{4}');

      When-validate-item trigger:

      if NOT numeric(:block.item) then
      message('invalid item');
      end if;

      => when I entered *0123* or *1234* should be acceptable ..but always the message displayed is "invalid item"

      Any suggestions?
        • 1. Re: Regular Expression
          The value 0123 is not a number, but a character. So, your item cannot not be NUMBER, but has to be CHAR.

          But it is way easier to use standard Forms functionality for this. Create a Char item with these properties:
          Maximum length = 4
          Fixed Length = Yes
          Format Mask = 9999