<%@ 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 // TODO: not working. </script> <!DOCTYPE html> <html lang="en"> <head runat="server"> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <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=/AJAXEngine/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:Banner ID="Banner1" runat="server" /> <a style="position: absolute; right: 32px; top: 10px" href="../ViewSrc.aspx">View Source</a> <mh:Title runat="server" /> <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/ web site.
For updates and discussions see http://ajaxaspects.blogspot.com/.