Hi, we are using oracle forms... we have to protect (or) block a text item field from special charecters. like ( !@#$%^&*) please send some guidences.... thanks in advance...
Regards, Vijay
Hi, we are using oracle forms... we have to protect (or) block a text item field from special charecters. like ( !@#$%^&*) please send some guidences.... thanks in advance...
Regards, Vijay
When your text box as some entered text you got to have a function that validates all input.
On that function you have a range off invalid values. That range is made in ASCII.
Which version of forms?
Brute force method:
v_prohibited_chars VARCHAR2(100) := '!@#$%^&*';
v_result VARCHAR2(4000);
...
-- strip prohibited characters
v_result := TRANSLATE(:form_field,'A'||v_prohibited_chars,'A');
-- if anything was stripped, lengths will differ
IF LENGTH(:form_field) <> LENGTH(v_result) THEN
error...
END IF
If I understand your comment correctly, you want to be able to filter the special character(s) out of the form field?
The above code does that, and places the result in v_result. So, if you have an input value of 'ABC#DEF#', and your filter mask is '!@#$%^&*', then after executing TRANSLATE your result will be 'ABCDEF'. You can then reassign this value to your form field. If you just want to silently strip the character, you can skip the LENGTH checking and simply assign the output of TRANSLATE back to your form field:
:form_field := TRANSLATE(:form_field,'A'||v_prohibited_chars,'A');
What TRANSLATE does is check the characters in the first parameter against the characters in the second parameter. When it finds a match, it translates that character into the corresponding character in the third parameter. If no corresponding characters exist in the third parameter for one in the second, then the character is translated to NULL. If a character does not appear in the second parameter, it remains unchanged. So, the character 'A' is translated to 'A', and all of the other characters in the mask are translated to NULL. The third parameter cannot be NULL, hence the dummy translation of 'A' to 'A'.