首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

文本框在鼠标离开时触发JS步骤

2012-08-29 
文本框在鼠标离开时触发JS方法%@ Page LanguageC# AutoEventWireuptrue CodeBehindWebForm1.aspx

文本框在鼠标离开时触发JS方法

<%@ 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>    <form id="form1" runat="server">    <div>        <asp:TextBox ID="txtName" onblur="validate();" runat="server" />    </div>    </form></body></html>

热点排行