This content has been marked as final. Show 3 replies
Syed_Wajahat_Kareem wrote:As salamualikum brother Syed Wajahat Kareen,
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.
Hope this helps..
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;
If someone's response is helpful or correct, please mark it accordingly.
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;
If you want to detect the presence of any digits in an varchar2 field, this is what I use:
<pre>If nvl(:Block.item,'~') <> 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.