I have an item in a form which is a number field and I want to somehow make sure that only numbers are accepted in the field. If users enter letters I want the field to reject it.
I already tried a validation but it was unsuccessful, is there anyway I get make this happen via a dynamic action with either a javascript code or a "pl/sql code"?
There's absolutely nothing you should do except setting its type to Number field.
Yes, you can type anything you want into it, but Oracle won't store anything but numbers. It'll raise the "Field name must be numeric" error and stop.
Why would you want to reinvent the wheel?
If you must, try with dynamic action on that item (let's call it P13_DEPTNO)
.
When event: Key Press
Selection type: Item
Item: P13_DEPTNO
True action: execute PL/SQL code (with "Items to submit": P13_DEPTNO):
begin
if not regexp_like(:P13_DEPTNO, '^\d+$')
then
raise_application_error(-20000, 'Digits only');
end if;
end;