更新时间:2022-02-02 21:42:02
是的,您可以使用Dynamic Action
和JavaScript函数apex.server.process
创建服务器端验证.
Yes, you can create server side validation by using Dynamic Action
and JavaScript function apex.server.process
.
一个基本的例子来演示-
A basic example to demonstrate-
在下面的代码中,我正在检查P4_ITEM值,您可以编写自己的逻辑进行验证.
In below code I am checking the P4_ITEM value, you can write your own logic to validate.
BEGIN
IF :P4_NAME = 'HIMANSHU'
THEN
HTP.prn ('SUCCESS');
ELSE
HTP.prn ('ERROR');
END IF;
END;
在代码部分中,像下面一样实现apex.server.process
-
In code section, implement apex.server.process
like below-
apex.server.process('validate_name',
{
pageItems : '#P4_NAME'
}
,
{
dataType : 'text', success : function(data)
{
if(data != 'SUCCESS')alert(data);
}
}
)
第一个参数是我们之前创建的页面流程名称(validate_name),第二个是您要提交给流程的数据,第三个是选项. 有关 apex.server.process
The first argument is the page process name(validate_name) which we have create earlier, second the data you want to submit to the process and third is options. For more details on apex.server.process
完成了.刷新页面并检查.验证失败时,您会收到警报.
It is done. Refresh your page and check. On validation failure you will get an alert.
您可以进一步自定义JS代码,以更精致的方式显示错误消息,而不是显示警报.
You can customize your JS code further to display error messages in more fancy way instead of showing alert.