<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ControlsExample3.aspx.cs" Inherits="FormControls.ControlsExample3" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>WFC Example: Client-Side Intercept</title>
<script lang="javascript" type="text/javascript">
function Validate() {
var amount = document.getElementById("txtAmount").value;
if (isNaN(amount)) {
alert("You must enter a number");
return false;
}
else if (amount < 100) {
document.getElementById("lblDisplay").innerHTML = "From the Client: The amount must be 100 or
more."
return false;
}
else if (amount >= 100) {
document.getElementById("lblDisplay").innerHTML = "From the Client: The amount must OK."
alert("That amount is OK.");
return true;
}
}
</script>
</head>
<body>
<h3>Method 1: Intercepting a Web Form (ASPX) Control on the
client-side <br />
The client-side script can also stop
the form submission.</h3>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" ForeColor="#000099"
Text="Enter an amount:"></asp:Label>
<br />
<asp:TextBox ID="txtAmount" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="btnSubmit" Text="Submit" OnClientClick="return Validate();" runat="server" Width="77px" OnClick="btnSubmit_Click" />
<br />
<asp:Label ID="lblDisplay" runat="server" ForeColor="#CC3300"></asp:Label>
</form>
</body>
</html>