View previous topic :: View next topic
|
Author |
Message |
sindhu_raghu Currently Banned New User
Joined: 18 Mar 2009 Posts: 7 Location: trichy
|
|
|
|
how to validate a field in a map?
suppose if the field in a map contains a phone number, how to check whether its number or not ?
i have given the code as
ELSE IF CPHNOL = 0 OR CPHNOI IS NOT NUMERIC THEN
MOVE 'CUSTOMER PHONE NUMBER IS INVALID' TO MSGO
but its not working
where CPHNOL is phone number field |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
but its not working |
the symptom is a bit generic ... don' t You think so? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
The first order of business is to define the rules for what constitutes a valid phone number. Then you need to implement code that enforces all of the rules.
Quote: |
but its not working |
As mentioned - you provided nothing to help anyone help you. . . Posting "it didn't workig" simply wastes everyone's time.
Does the code complie correctly? Does the code abend? Does the code throw some programmed error (like the one you show in the bit of code)?
You need to post what the input contained and the result from that input. |
|
Back to top |
|
|
sindhu_raghu Currently Banned New User
Joined: 18 Mar 2009 Posts: 7 Location: trichy
|
|
|
|
yeah thats code is not abending and its not giving compiler error
but the validation is not done properly |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
What is the definition of CPHNOL and what does it contain? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
but the validation is not done properly |
You need to post the definition of "properly". If the rules are not known it just wastes time.
Show what values you use as input and what should happen for each input used. FWIW - the posted code does very little to validate a phone number. . .
Do not post "it is not working". . . |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
ELSE IF CPHNOL = 0 OR CPHNOI IS NOT NUMERIC THEN
MOVE 'CUSTOMER PHONE NUMBER IS INVALID' TO MSGO
but its not working
where CPHNOL is phone number field |
Actually, I presume CPHNO is the map field -- CPHNOL would be the length attribute while CPHNOI would be the input map field. It appears you're checking to see if the field was not input (length of zero) or if the field is not numeric. That's not much of a validation routine, and you can't really tell which condition triggered the message. I suggest having one validation IF with message, then another validation IF with message so you can tell which condition is triggering a message. Something like:
Code: |
ELSE IF CPHNOL = 0
MOVE 'CUSTOMER PHONE NUMBER NOT INPUT' TO MSGO
ELSE IF CPHNOI IS NOT NUMERIC THEN
MOVE 'CUSTOMER PHONE NUMBER NOT NUMERIC' TO MSGO
|
Furthermore, most countries have pretty extended rules for what is a phone number that can be used for validation. |
|
Back to top |
|
|
|