Return to the menu   Select another DES Module

Demonstrates the EmailAddressValidator

The EmailAddressValidator reviews the text of an email address to confirm that it matches valid email address patterns. In addition, you can hook it up to a third party email validation engine.

Specify the textbox to evaluate with the ControlIDToEvaluate property.

If you want to allow multiple email addresses in the same textbox, set MultipleAddressesAllowed to true. You can define the delimiter character in DelimiterCharacter, which defaults to a semicolon. You can allow spaces after the delimiter when DelimiterAllowsSpaces is true.

If you want an error reported for a blank textbox, set IgnoreBlankText to false.

If you are using a third party validation engine, set up the OnEmailAddressValidate event handler to call that engine and return true if the email address is valid.


Controls

Example 1

One email address allowed.



Example 2

This allows multiple email addresses separated by a semicolon and optional space.




Source Code (C#)

<script runat="server">
protected void Button1_Click(object sender, EventArgs e) { if (PeterBlum.DES.Globals.WebFormDirector.IsValid) { // save your data here } }
</script> <h2>Example 1</h2> One email address allowed.<br/><br/> <des:TextBox ID="TextBox1" runat="server" /> <des:EmailAddressValidator ID="EmailAddressValidator1" runat="server" ControlIDToEvaluate="TextBox1" ErrorMessage="Invalid email address" /> <br/> <br/> <h2>Example 2</h2> This allows multiple email addresses separated by a semicolon and optional space.<br/><br/> <des:TextBox ID="TextBox2" runat="server" /> <des:EmailAddressValidator ID="EmailAddressValidator2" runat="server" ControlIDToEvaluate="TextBox2" ErrorMessage="Invalid email address" MultipleAddressesAllowed="true" DelimiterCharacter=";" DelimiterAllowsSpaces="true" /> <br/> <br/> <des:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click"></des:Button>

Return to the menu   Select another DES Module