开发者

How to check if a textbox is empty and return an error using PSP

I am using PL/SQL Server Pages to retrieve data from database. I have 2 files, first.psp and second.psp

In first.psp, I wrote the code for a textbox using input tag and the name of this textbox is 'age'. In second.psp, I declared age as parameter using

--> <%@ plsql parameter = "age" type = "VARCHAR2"%>

In the form tag of first.psp, I used method = "post" and action = "second.psp"

Now I want to check if the textbox value is a number, otherwise return error. It should also return error if the textbox is empty. If I say,

IF age = ' ' THEN

/print error/

ELSE

/blah blah blah/

END IF;

and while running the first.psp in the browser, I fill nothing in the textbox, even then the control goes to ELSE part开发者_运维知识库 but it actually should go to the IF part. Can anyone please tell me where I am going wrong?

Thanks.


If PL/SQL server pages are following the same rules as used elsewhere in Oracle products, an empty string is the same thing as NULL. However, you can't compare for equality with NULL. Try

IF age IS NULL THEN

and see if it works as you expect.

Share and enjoy.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜