This discussion is archived
1 Reply Latest reply: Mar 20, 2013 10:10 AM by InoL RSS

Regular Expression

982158 Newbie
Currently Being Moderated
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
    InoL Guru
    Currently Being Moderated
    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


  • Correct Answers - 10 points
  • Helpful Answers - 5 points