stop numeric in alpha field

Discussions about CSEntry
Post Reply
rameshpal99

stop numeric in alpha field

Post by rameshpal99 » January 30th, 2013, 10:28 am

Dear Sir,

I have request to you for stop numeric in alpha field.

Thanks
Ramesh

khurshid.arshad
Posts: 423
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: stop numeric in alpha field

Post by khurshid.arshad » February 4th, 2013, 12:30 am

Dear;

Please see this code:


PROC GLOBAL

Function OnKey(x);
if getsymbol()="RESPONDENT" or getsymbol()="INTERVIEWER" or getsymbol()="UC_NAME" or
getsymbol()="CONTACT_PERSON" then
if x in 65:90,13, 8, 32, 46, 37:40, 219,221 then { Alpha "65:90, 13=Enter, 8=Bksp, 32=Space, 46=Delete}
OnKey = x;
else
OnKey = 0;
endif;
elseif getsymbol()="LATITUDE" or getsymbol()="LONGITUDE" then \\If you want enter only Numeric in Text Field
if x in 48:57,96:105,110, 46, 8, 13 then { Numeric "48:57, keypad=96:105, decimal = 110,8=Bksp, 46=Delete, 13=Enter}

OnKey = x;
else
OnKey = 0;
endif;
else
Onkey = x;
endif;

end;

Regards.
Arshad

Gregory Martin
Posts: 1338
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: stop numeric in alpha field

Post by Gregory Martin » February 4th, 2013, 2:14 pm

There is no way to do this for every alpha field. You will have to do something similar to what Arshad mentioned, where you override the OnKey function and specify the fields where you don't want numeric values entered. Something like this:
function OnKey(keystroke)

    OnKey = keystroke;

    
if getsymbol() in "ALPHAFIELD1","ALPHAFIELD2","ALPHAFIELD3" then
        
        
if keystroke in 48:57 then
            OnKey =
0; // disable the keystroke
        endif;
    
    
endif;

end;

Bharadwaj

Re: stop numeric in alpha field

Post by Bharadwaj » February 9th, 2013, 2:06 pm

Dear Ramesh

If you are unable to understand above two functions you can use following syntax in Alpha field postproc to avoid other characters

i = 0;
do while i < 30
if not $[i:1] in "A":"Z" then
errmsg("Check entered Name");
reenter;
endif;
i = i +1;
enddo;

Regards

Bharadwaj

Post Reply