Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare email entry validation 1

Status
Not open for further replies.

quork

Programmer
Oct 20, 2009
18
US
It's been a long time since I used Clarion. Now, I am back using it. I'm using ClarionPE verson 6.3 etal.

In one of my forms I have an email input field where the user enters their email address. I want to have a second email input field on the form to act as confirmation that they typed in their email address correctly.

Is there a simple way to do this in Clarion? I thought about setting up a local variable and using it as the confirmation input field. Then simply comparing the two email input fields. If they match then great. If they don't match, then the user gets an error message explaining the error and that they must retype both email entries.

The problem is I don't know how and if to code this properly. I'm surprised that there isn't a built-in function in the Clarion IDE to do this sort of thing.

I was hoping this wouldn't turn into a coding nightmare for me.

Any help would be very very much appreciated.
 
Hi!

Just add a local variable called LOC:EmailCopy and populate it on the window. In the Accepted embed of LOC:EmailCopy OR WindowManager - TakeCompleted - before parent call i.e. before saving the form, do the following ::

IF FIL:EMail <> '' AND LOC:EMailCopy <> FIL:EMail
MESSAGE('E-Mail Address DO NOT MATCH','E R R O R')
SELECT(?LOC:EMailCopy)
CYCLE
END

You can also validate the syntax of E-Mail addresses using the MATCH function as follows ::

IF NOT MATCH(UPPER(CLIP(FIL:EMail)), '^[-A-Z0-9._]+@{{[-A-Z0-9._]+.}+[A-Z][A-Z][A-Z]?[A-Z]?$', Match:Regular)
MESSAGE('E-Mail Address is INCORRECT','E R R O R')
SELECT(?FIL:EMail)
CYCLE
END

Regards
 
Once again you saved me. I thank you very much. I will try not to post here unless I have exhausted all research avenues.
 
Shankar, I have run into a problem with the email comparison routine. I have set up the input form so that it stays open after the user clicks on submit. Thus, it's ready for the next record to be input. Unfortunately, the LOC:EMailCopy field does not clear. Data from the previous entry remains in the input field. Otherwise, as I posted earlier, it works great.

I feel guilty asking for your help again. I hope you will forgive my seemingly novice-like questions.

 
Hi!

The following will clear the contents and display it.

CLEAR(LOC:EMailCopy) ; DISPLAY(?LOC:EMailCopy)

The suggested usage ::

Code:
IF FIL:EMail <> '' AND LOC:EMailCopy <> FIL:EMail
   MESSAGE('E-Mail Address DO NOT MATCH','E R R O R')
   SELECT(?LOC:EMailCopy)
   CYCLE
ELSE
   CLEAR(LOC:EMailCopy) ; DISPLAY(?LOC:EMailCopy)
END

Regards
 
Hi Shankar,

I'm sorry to report that when I add the line of codeper your suggested usage a problem arises. As soon as I leave the LOC:EMAILCOPY field to go to the next field, the emails do not match error message pops up.

This is the code I am using:

IF EMA:EMail <> '' AND LOC:confirm_email <> EMA:EMail
MESSAGE(' E-Mail Addresses DO NOT MATCH. Please re-enter','E R R O R !')
SELECT(?LOC:confirm_email)
CYCLE
ELSE
CLEAR(LOC:confirm_email) ; DISPLAY(?LOC:confirm_email)
END

Do you have a suggestion to cure this?
 
Hi!

Since I assume you are validating the e-mail when it is entered for the first time or changed, I would suggest the following ::

- Create a Local variable called SAV:EMail similar to EMA:Email
- In the WindowManager.Init - after open files embed - save the current value in the table
Code:
 SAV:EMail = EMA:EMail
 LOC:confirm_email = EMA:EMail
- On EMA:EMail - Accepted embed - after parent call, do the following ::
Code:
IF EMA:EMail <> '' AND EMA:EMail <> SAV:EMail
   CLEAR(LOC:confirm_email) ; DISPLAY(?LOC:confirm_email)
END
This clears the local variable whenever the E-Mail value changes.
- On LOC:confirm_email - Accepted Embed - after parent call, do the following ::
Code:
IF EMA:EMail <> '' AND LOC:confirm_email <> EMA:EMail
   MESSAGE(' E-Mail Addresses DO NOT MATCH. Please re-enter','E R R O R !')
   SELECT(?LOC:confirm_email)
   CYCLE
ELSE
   SAV:Mail = EMA:EMail
END
This checks if the e-mail value matches and if they are matched re-saves the value to the SAV:EMail.

Regards





 
Shankar, I'm a bit confused about the first part of your instructions:

"In the WindowManager.Init - after open files embed - save the current value in the table"

If this is to be inserted as an embed, I'm not sure where I find the entry point for this embed. I am ashamed to ask, but could you explain this part as if explaining to a 6-year old?

Thank you for your patience.
 
Hi!

Are you using the ABC or Clarion template chain? If you are not sure check Application -> Properties. If you are using the Clarion (Legacy) chain, you can execute that code at the beginning of the procedure after opening the files.

Regards
 
Hi Shankar, I'm happy to report that I have had success. I placed this code

SAV:EMail = EMA:EMail
LOC:confirm_email = EMA:EMail

In the following ABC CODE section embed point:

PrimeFields Procedure VIRTUAL


It seems to work perfectly.

Thank you as always, for your tremendous help. This really means a lot to me. Best wishes and have a great day.

 
Hi!

Prime fields will work only for Inserts. So, how will you handle a Change when the user changes the e-mail?

Since you are using ABC, go to Embeds and make sure "Show Filled Only" (icon with RED equal sign) is OFF. This will show all the embed points. WindowManager.Init can be found under Local Objects -> ABC Objects -> Window Manager -> Init -> Code -> Place bar on Open Files and press insert to add an embed after it and copy the required code there. WindowManager is the class that manages the window and Init is the first method which is called.

Regards
 
Hi Shankar,

I placed the code in:

Local Objects -> ABC Objects -> Window Manager -> Init PROCEDURE(),BYTE,VIRTUAL -> Open Files

However, the data still appears in the LOC:confirm_email field on the form.

I neglected to mention that this is a continuous form. That is, when the user clicks on OK, the form clears and is ready for new input data. It does not return to the browse window. This was my preferred method.
 
Hi!

Placing the code in WM.Init helps when the user tries to change a row/record i.e. the user is NOT prompted to confirm the e-mail unless they change it. FYI, WM.PrimeFields will not be called on a Change operation.

Since it is a continuous entry, place the code (SAV:EMail = EMA:EMail ; LOC:confirm_email = EMA:EMail) in WM.Init & WM.PrimeFields. That should take care of Insert & Change operations.

Regards
 
Shankar, I installed that code in the two places you directed me to. Everything works perfectly now.

I can't thank you enough. Your patience with me is a credit to your professionalism.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top