<%@ Page Language="C#" %> <script runat="server"> // ValidatorDemo.aspx // Sample page to show the Validation Control extended by an AJAX functionality. // Copyright (c) by Matthias Hertel, http://www.mathertel.de // This work is licensed under a BSD style license. See http://www.mathertel.de/License.aspx // ----- // 27.09.2005 created by Matthias Hertel // 03.10.2005 published </script> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Validator Demo</title> <link href="../mathertel.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="../ajaxcore/ajax.js"></script> <script type="text/javascript" src="../ajaxcore/GetJavaScriptProxy.aspx?service=~/S03_AJAXControls/ValidatorDemo.asmx"></script> <script type="text/javascript"> function validateEMail(source, arguments) { ajax.Start(validateAction, source); } // validateEMail var validateAction = { delay: 0, prepare: function (source) { // from the Validator Common JavaScript return(ValidatorGetValue(source.controltovalidate)); }, call: proxies.ValidatorDemo.ValidateEMail, finish: function (val, source) { // from the Validator Common JavaScript source.isvalid = val; if (! val) Page_IsValid = false; ValidatorUpdateDisplay(source); ValidationSummaryOnSubmit(null); }, onException: proxies.alertException } // validateAction </script> </head> <body> <mh:Title ID="Title" runat="server" /> <a href="../ViewSrc.aspx" style="position: absolute; right: 10px; top: 10px">View Source</a> <hr /> <form id="form1" runat="server"> <div> <table> <tr> <td><label>Name:</label></td> <td><input autocomplete="off" id="NAME_IN" runat="server" name="NAME" /> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="NAME_IN" runat="server" ErrorMessage="A name is required."></asp:RequiredFieldValidator></td> </tr> <tr> <td><label>E-Mail:</label></td> <td><input autocomplete="off" id="EMAIL_IN" runat="server" name="EMAIL" /> <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="EMAIL_IN" ErrorMessage="Please enter a valid e-mail address." ClientValidationFunction="validateEMail">*</asp:CustomValidator></td> </tr> </table> <input type="submit" value="Register" style="height: auto" /> </div> <asp:ValidationSummary ID="ValidationSummary1" EnableClientScript="true" ShowSummary="true" runat="server" DisplayMode="List" HeaderText="Errors on the form:" ShowMessageBox="False" /> <p><span style="color: Red">Hint:</span> To start the AJAX based asynchronous verification enter a valid or invalid email address into the E-Mail field and leave this field.</p> <p>You do not have to press the button! The entered eMail address will be checked for a valid domain name using a DNS request that is executed on the server.</p> <p>DNS lookups are not really fast so it can take a second before the verification asnwer is shown when the host in unknown on the internet.</p> <mh:Footer ID="foot" runat="server" /> </form> </body> </html>
This page is part of the http://www.mathertel.de/AJAXEngine/default.aspx project. For updates and discussions see The AJAX Engine blog.
For updates and discussions see http://ajaxaspects.blogspot.com/.