We have a number of pages in PeopleSoft, where user/admin is free to enter email addresses. How to validate if a value entered in a PeopleSoft field is a valid email address?
In general, how does an email id look like? It will have few characters followed by @ symbol followed by few characters and then a .(dot) symbol followed by few more characters. So, we have to validate the presence of these.
For example, if &email_addr is a variable which contains the string entered in email address field and needs to be validated then try the below code:
&AT = Find("@", &email_addr);
&DOT = Find(".", &email_addr);
If ALL(%AT,&DOT) Then
/* Validation Success */
/* Validation Fail*/
/* Issue Error message */
Additionally we could also perform checks to ensure that:
- the position of @ is not the first character
- .(dot) is not the last character.
- @ is not repeated else where in the string
- Dot is not repeated else where in the string
This can be done by using instr, substr and len functions.
HAPPY LEARNING :)