Home » Developer & Programmer » Forms » How to validate the alphanumeric and symbol in textbox (Developer Suite 10g, Database 10g)
How to validate the alphanumeric and symbol in textbox [message #570549] |
Mon, 12 November 2012 01:43 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
|
I have created a form that have a button to check the character in the textbox is alphanumeric and symbol.
Here attached the code, that i tried from other post.
Can somebody fix this.
I tried a couple a week ..but cannot be resolved.
Thanks a lot.
Regards,
pakrul
|
|
|
Re: How to validate the alphanumeric and symbol in textbox [message #570570 is a reply to message #570549] |
Mon, 12 November 2012 06:35 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13938 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Next time post you code directly in the thread using code tags as described here: How to use [code] tags and make your code easier to read?
A lot people can't/won't download attachments.
It would also help if explained exactly how the code is not working - are you getting error? Does it do something you don't expect?
What you want can be done simply with the translate function:
SQL> SELECT trim(TRANSLATE('BASD$%',
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&()''*+,-/:;<=>?_',
2 3 ' ')
4 )
5 FROM dual;
T
-
SQL> SELECT trim(TRANSLATE('BA12 %^%',
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&()''*+,-/:;<=>?_',
2 3 ' ')
4 )
FROM dual; 5
TRIM(TRANSLATE(
---------------
12 ^
If the string returned by the above is anything other than null then you have disallowed characters
[Updated on: Mon, 12 November 2012 06:35] Report message to a moderator
|
|
|
Re: How to validate the alphanumeric and symbol in textbox [message #570618 is a reply to message #570570] |
Mon, 12 November 2012 23:07 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
|
Based on code below.
First..if i put all alphaphet. it shows number(digit) error not the alphabet.
Second ..If i put the digit. It shows alphabet error..
Third...If I put alphabet and digit..it shows no symbol input..
forth... If I put alphabet, digit and symbol...stil it say.."No symbol input" and cannot be saved..
Is it my code wrong or I missed some thing.
If i put that code as a function and return the boolean...How to call it use "when the button pressed" in PL/SQL.
Thanks.
DECLARE
alert_button number;
chararray VARCHAR2(52);
digitarray VARCHAR2(20);
ischar BOOLEAN;
isdigit BOOLEAN;
ispunct BOOLEAN;
m INTEGER;
n BOOLEAN;
i integer;
j integer;
punctarray VARCHAR2(25);
BEGIN
digitarray := '0123456789';
chararray := 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
punctarray := '!"#$%&()''*+,-/:;<=>?_';
if :block1.BARU is null then
alert_button := Show_Alert('password');
go_item('block1.BARU');
raise form_trigger_failure;
-- check for minimum password length
elsif length(:block1.BARU)< 8 then
alert_button := Show_Alert('panjang');
go_item('block1.BARU');
raise form_trigger_failure;
-- check for common words
ELSIF :block1.baru IN ('welcome', 'password', 'oracle', 'computer', 'abcdef') THEN
alert_button := Show_Alert('biasa');
go_item('block1.BARU');
raise form_trigger_failure;
end if;
go_block('block1');
isdigit := FALSE;
m := LENGTH(:block1.baru);
FOR i IN 1..25 LOOP
FOR j IN 1..m LOOP
IF SUBSTR(:block1.baru,j,1) = SUBSTR(digitarray,i,1) THEN
isdigit := TRUE;
GOTO findchar;
END IF;
END LOOP;
END LOOP;
IF isdigit = FALSE THEN
alert_button := Show_Alert('digit');
go_item('block1.BARU');
raise form_trigger_failure;
END IF;
<<findchar>>
ischar := FALSE;
FOR i IN 1..LENGTH(chararray) LOOP
FOR j IN 1..m LOOP
IF SUBSTR(:block1.baru,j,1) = SUBSTR(chararray,i,1) THEN
ischar := TRUE;
GOTO findpunct;
END IF;
END LOOP;
END LOOP;
IF ischar = FALSE THEN
alert_button := Show_Alert('char');
go_item('block1.BARU');
raise form_trigger_failure;
END IF;
<<findpunct>>
ispunct := FALSE;
FOR i IN 1..LENGTH(punctarray) LOOP
FOR k IN 1..m LOOP
IF SUBSTR(:block1.baru,j,1) = SUBSTR(punctarray,i,1) THEN
ispunct := TRUE;
GOTO endsearch;
END IF;
END LOOP;
END LOOP;
IF ispunct = FALSE THEN
alert_button := Show_Alert('symbol');
go_item('block1.BARU');
raise form_trigger_failure;
end if;
<<endsearch>>
FORMS_DDL('ALTER USER '||:block1.login||' IDENTIFIED BY '||:block1.BARU);
commit;
alert_button := Show_Alert('SUCCESS');
exit_form;
END;
|
|
|
Re: How to validate the alphanumeric and symbol in textbox [message #570620 is a reply to message #570618] |
Tue, 13 November 2012 00:09 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](http://www.orafaq.com/forum/images/custom_avatars/72104.gif) |
Littlefoot
Messages: 21818 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
It is awfully formatted. Read link Cookiemonster provided once again, please.
As of your code: work on it some more! Show your debugging skills! If it is too complex now, start from scratch, solving ONE problem at a time (the first one you mentioned; when you are satisfied with it, move on to the second one, and so forth).
As of a function returning Boolean: depending on what it returns (TRUE because input string is OK, or FALSE because it is not; or, you might even turn the logic upside down and return FALSE if the string is OK, but that's rather confusing). Suppose that it returns TRUE for a valid input. Then you'd do something like this:
if f_input_ok then
message('Congratulations, you did it right!');
else
message('Nope, something went wrong');
end if;
|
|
|
|
Re: How to validate the alphanumeric and symbol in textbox [message #570665 is a reply to message #570621] |
Tue, 13 November 2012 22:59 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
|
Thanks to all i Just put like Cookiemonster say....
Then I got message success...................and everything is fine..
Thanks again..
DECLARE
alert_button number;
BEGIN
if :block1.BARU is null then
alert_button := Show_Alert('password');
go_item('block1.BARU');
raise form_trigger_failure;
-- check for minimum password length
elsif length(:block1.BARU)< 8 then
alert_button := Show_Alert('panjang');
go_item('block1.BARU');
raise form_trigger_failure;
-- check for common words
ELSIF :block1.baru IN ('welcome', 'password', 'oracle', 'computer', 'abcdef') THEN
alert_button := Show_Alert('biasa');
go_item('block1.BARU');
raise form_trigger_failure;
elsif length(TRIM(TRANSLATE(:BLOCK1.BARU,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',' ') )) is null then
alert_button := Show_Alert('char');
go_item('block1.BARU');
raise form_trigger_failure;
elsif length(TRIM(TRANSLATE(:BLOCK1.BARU,'0123456789',' '))) is null then
alert_button := Show_Alert('digit');
go_item('block1.BARU');
raise form_trigger_failure;
elsif length(TRIM(TRANSLATE(:BLOCK1.BARU,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!"#$%&()''*+,-/:;<=>?_',' ' ))) is null then
FORMS_DDL('ALTER USER '||:block1.login||' IDENTIFIED BY '||:block1.BARU);
commit;
alert_button := Show_Alert('SUCCESS');
exit_form;
end if;
END;
|
|
|
Goto Forum:
Current Time: Wed Sep 18 21:18:15 CDT 2024
|