‎2008 May 27 11:46 AM
I am working on a dialogue programme in which there are various fields like firstname, lastname, phoneno,age etc etc.., I need to validate the phoneno and age fields such that it should not accept anything but numericals, how can i do that!!!
sample code i am using is this -
*PHONE NUMBER VALIDATIONS
IF PHONENO CN 'ABCDEFGHIHJK'.
MESSAGE I017(YMESS).
RETURN.
ENDIF
sushanth.
‎2008 May 27 11:49 AM
Hi,
use a numeric field as type reference to the age and phone no fields. ..
that will validate automatically
regards,
lavanya
‎2008 May 27 11:51 AM
hi
validate ur fields in
PBO event of driver program with in
CHAIN
ENDCHAIN.
u can refer CHAIN ENDCHAIN. example .
reward if helpful.
‎2008 May 27 11:57 AM
hi sushant,
Use CHAIN ..... ENDCHAIN for validation of fields in Dialog prog. for detailed help abt the code, use help on Chain ... Endchain.
Thanx.
Khan
‎2008 May 27 11:58 AM
data : num type i.
data : n type i value 0.
data cpos type c.
parameters : input(30) type c.
field-symbols : <fs> type any.
num = strlen( input ).
do num times.
assign input+n(1) to <fs>.
if <fs> = '1'
or <fs> = '2'
or <fs> = '3'
or <fs> = '4'
or <fs> = '5'
or <fs> = '6'
or <fs> = '7'
or <fs> = '8'
or <fs> = '9'
or <fs> = '0'.
add 1 to n.
continue
else.
add 1 to n.
write 'error in input'.
endif.
enddo.
‎2008 May 27 12:00 PM
Hi Sushanth,
Using the numeric fiends is the best solutions, as it will handle by default so that it will not allow the alphabets or any special characters, instead if you want to validate the existing Character fields on the screen you can validate by using the FIELD, CHAIN-ENDCHAIN.
To check this take the Length(say len1) of the screen field that you want to validate and move that field value to NUMC variable(var1) (declare that variable in you program), and after you move the original value to var1, again check the length for var1 (say len2). Now you compare both var1 and var2. if they are not equal to each other, then there will some character field exist in field that you want to validate.
Now you can throw the error message that 'please enter numeric value only'.
Please reward the points if helpful.