This discussion is archived
3 Replies Latest reply: Feb 4, 2013 9:42 PM by user346369 RSS

Check Numeric Data in name text field

791102 Newbie
Currently Being Moderated
I have worked over the forms long time ago , Recently i am facing a problem in detection of any numeric value in text box. I also forget the trigger which on entering numeric data gives alert to user , so he can place only character values A-z.
Thankx
  • 1. Re: Check Numeric Data in name text field
    HamidHelal Guru
    Currently Being Moderated
    Syed_Wajahat_Kareem wrote:
    I have worked over the forms long time ago , Recently i am facing a problem in detection of any numeric value in text box. I also forget the trigger which on entering numeric data gives alert to user , so he can place only character values A-z.
    Thankx
    As salamualikum brother Syed Wajahat Kareen,

    try this..
    declare
     b varchar2(10);
     
    begin
    FOR I IN 1..LENGTH(:Item_WORD) LOOP
    B := SUBSTR(:Item_WORD,I,1);
     if b in ('1','2','3','4','5','6','7','8','9','0') then
      message('not allowed.');
      message('not allowed.');
      raise form_trigger_failure;
     end if;
     
     
    END LOOP;
     
    end;
    Hope this helps..

    Hamid

    If someone's response is helpful or correct, please mark it accordingly.
  • 2. Re: Check Numeric Data in name text field
    MLBrown Journeyer
    Currently Being Moderated
    You could also add logic to your WHEN-VALIDATE-ITEM trigger to assign the item to a numeric field at let the exception process take care of it for you. Something like:
    -- 
    -- WHEN-VALIDATE-ITEM: Insure item is numeric.
    -- 
    declare
      v_number     number;
    begin
      v_number := :BLOCK.ITEM;  -- Where BLOCK is the name of your block and ITEM is the name of your item.
    exception
      when value_error then
        message('Only numeric characters allowed in this field!');
        message('Only numeric characters allowed in this field!');
        raise form_trigger_failure;
    end;
  • 3. Re: Check Numeric Data in name text field
    user346369 Expert
    Currently Being Moderated
    If you want to detect the presence of any digits in an varchar2 field, this is what I use:

    <pre>If nvl(:Block.item,'~') &lt;> nvl(translate(:Block.item,'A0123456789','A'),'~') then...</pre>

    In this case, the Translate function replaces the 0123456789 characters with null, so the result would be different from the original value.

    You would normally check the field in a When-Validate-Item trigger.

Legend

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