Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Validation of input fields

Former Member
0 Kudos

Hi,

I have a dialog progarm which has 3 fields :

Name,Email ID,Passport no.

I have to validate them as below:

Name : only characters allowed with spaces.

Email Id: There should be one @ in between and one dot after @.

Passport no : It should be alphanumeric field.

I have tried the validation for name as

it_table-name CN sy-abcde.

But its not working. Please suggest the solution.

6 REPLIES 6

Former Member
0 Kudos

its better to validate explicitly.

For ex: if p_name CA 'abcdefhijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '

DO NOTHING

else.

trigger ur error message.

endif.

Since you are allowingonly char values for name.

to validate email id for @ symbol...(i may be wrong syntactically.take f1 help and code the correct syntax)

declare g_count as type i and temp_emailid as type p_emailid.

clear temp_emailid.

move the user i/p p_email to some temp_emailid.

replace '@' in temp_emailid on all occurences and count g_count.

if count > 1.

trigger ur error msg.

endif.

For passport number: same as coding in name validation except that, you have to remove the space at the end in the string as you cannot have space in passport number.

Thanks

Kiran

former_member226203
Active Contributor
0 Kudos

for name, u can declare it as character. after enetring the name jus do the validation like:

if v_name CO 'abcdefghijklmnopqrstuvwxyz ' then accept it else gve a message that it should contain only characters.

u can use the dataelement AD_SMTPADR for mail id. and check for the codition that . appears after @

u can use STRING for alphanumeric values.

Former Member
0 Kudos

Hi Sunil,

Check this Code,

For Name validation.


PARAMETERS: LMAIL TYPE ADR6-SMTP_ADDR.

IF LMAIL CO SY-ABCDE AND LMAIL CA ' '.
  WRITE : 'Success'.
ELSE.
  WRITE : 'Error'.
ENDIF.

For E-Mail Validation.


IF LMAIL CP '*@*.*'.
  IF LMAIL CA ' '.
    WRITE : 'Error'.
  ELSE.
    WRITE : 'Success'.
  ENDIF.
ENDIF.

For Passport validtion


Just declare the variable as NUMC (Var Type N).

Thanks & regards,

Dileep .C

Former Member
0 Kudos

Hi

data:

w_str type string.

concatenate sy-abcde space into w_str.

concatenate '@' '.' into w_str2 no gaps.

for name...

it_table-name CO w_str.

else.

// error message.

endif.

for mailid..

if w_mail CA w_str2.

endif.

for alpha numeric ( type string/char )restrict the special characters..

NA ' !@#$%^&*() '.

Regards

0 Kudos

Try Regular Expression....

1. For Name

'\[A-Ba-b\]* \[A-Ba-b\]*'

2. For Mail id

'@.*'

3. For Alpha Numeric field

'\[a-bA-B0-9\]*'

Edited by: Gyanendar Rathore on May 6, 2009 8:07 AM

Edited by: Gyanendar Rathore on May 6, 2009 8:09 AM

Former Member
0 Kudos

Hi Sunil,

Is your problem solved,

If so, Not even replying a thanks.

Can you please share the solution of your problem,

Thanks & regard,

Dileep .C