[csharp]
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="textBox.WebForm1" %>
<!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></title>
<script type="text/javascript">
function validate() {
var name = document.getElementById("txtName");
if (name.value == 2) {
alert("你必須不是二!");
name.focus();
return false;
}
return true;
}
</script>
</head>
<body> www.2cto.com
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtName" onblur="validate();" runat="server" />
</div>
</form>
</body>
</html>
作者:pengshumin89