I have a text box which asks for an e-mail address. How do I check whether the e-mail address is in the correct format before the next button is pressed.
Thanks
Posted 08 January 2002 - 10:39
I have a text box which asks for an e-mail address. How do I check whether the e-mail address is in the correct format before the next button is pressed.
Thanks
Posted 08 January 2002 - 16:03
You will need to trigger some sort of event before the Next button is pressed. Most likely you will need to have another button on the dialog to achieve this.
You could do the following. Add another button to the dialog, for this example I will call it Validate. Next create a Custom Action that runs some script, for this example I will use VBScript. Something similar to the following:
-------------------------------------------------------------------------
Option Explicit
Dim sVar
sVar = Session.Property("YourEmailControlProperty")
'Here is where you would insert code
'to do your Validation
If Instr(1, sVar, "@", 1) <> 0 Then
Session.Property("EmailValidate") = "True"
Exit Sub
Else
MsgBox "Wrong Format. Try Again"
Session.Property("EmailValidate") = "False"
End If
End Sub
------------------------------------------------------------------------
Of course this will only check for the existence of the @ sign but you can get as complex as you'd like.
Once this script has been created and you have created a Custom Action to run it, do the following. Go to the Dialog Behavior screen and select this new PushButton control (Validate). Do the following:
Event Argument Condition
--------------------------------------------------------------------------
DoAction YourCustomAction 1
Go into the Dialog Behavior screen and click on the Next button. Then switch to the Conditions tab for that control. Do the following:
Action Condition
--------------------------------------------------------------------------
Enable [EmailValidate] = "True"
Disable [EmailValidate] = "False"
By default I would create, in the Property Manager a property called [EmailValidate] and set it's value to False. This will ensure that the Next button is disabled whern the dialog is presented to the user. The Next button should only become Enabled when the [EmailValidate] property returns True.
I'm sure there are other ways to achieve this but I know that this one will do the trick.
Good Luck
Kurt
Posted 08 January 2002 - 20:42