Page 1 of 1

Fields with only Number and alphabet not special character

Posted: April 21st, 2013, 1:47 am
by Purushottam
I want logic for Fields(Alpha) that accept only Number (0-9) and alphabet (A-Z) not special character

Pl help

Re: Fields with only Number and alphabet not special charact

Posted: April 21st, 2013, 4:48 am
by khurshid.arshad
Please use this code in Global




Function OnKey(x);


if getsymbol()="Variable Name" then
if x in 65:90,13, 8, 32, 46, 37:40, 1009 ,48:57,96:105, 1009,190 then
{ Alpha "65:90, 13=Enter, 8=Bksp, 32=Space, 46=Delete; Numeric 48:57, keypad=96:105}
OnKey = x;
else
OnKey = 0;
endif;
else
Onkey = x;
endif;
end;

a.

Re: Fields with only Number and alphabet not special charact

Posted: April 21st, 2013, 7:03 am
by Bharadwaj
Purushottam wrote:I want logic for Fields(Alpha) that accept only Number (0-9) and alphabet (A-Z) not special character

Pl help
Hi Purushottam

Use simple logic

proc VAR

if not $ in "A":"Z", "0":"9" then
Errmsg("Please enter correct charecter");
reenter;
endif;


This will resolve your problem.

Re: Fields with only Number and alphabet not special charact

Posted: April 21st, 2013, 11:57 am
by Purushottam
Bharadwaj wrote:
Purushottam wrote:I want logic for Fields(Alpha) that accept only Number (0-9) and alphabet (A-Z) not special character

Pl help
Hi Purushottam

Use simple logic

proc VAR

if not $ in "A":"Z", "0":"9" then
Errmsg("Please enter correct charecter");
reenter;
endif;


This will resolve your problem.

Thanks Mr Bhardwaj,

I have VAR (PAN) with length 10 (e.g. PAN /TAN no). I want to enter PAN or TAN number with only A:Z and 0:9 only. how to enter on these characters only?
pl suggest

Re: Fields with only Number and alphabet not special charact

Posted: April 22nd, 2013, 5:47 pm
by Gregory Martin
To build off what Bharadwaj wrote, you can employ a loop to check all ten characters:
PROC PAN

numeric counter;

do counter = 1 while counter <= length(PAN)

    
if not toupper(PAN[counter:1]) in "0":"9","A":"Z"," " then
        
errmsg("Please enter a correct character");
        
reenter;
    
endif;

enddo;