Source Code

for file /AJAXEngine/S03_AJAXControls/ValidatorDemo.aspx

<%@ 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,
  // This work is licensed under a BSD style license. See
  // ----- 
  // 27.09.2005 created by Matthias Hertel
  // 03.10.2005 published
  // TODO: not working.
<!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
    call: proxies.ValidatorDemo.ValidateEMail,

    finish: function (val, source) {
      // from the Validator Common JavaScript
      source.isvalid = val;
      if (! val)
        Page_IsValid = false;
    onException: proxies.alertException
  } // validateAction

  <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">
          <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>
          <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>
      <input type="submit" value="Register" style="height: auto" />
    <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" />

This page is part of the web site.

For updates and discussions see