大数据之路

博客园 首页 新随笔 联系 订阅 管理
改方法有局限性需和文本框内的数据比较
 
 请输入6位号码

 1<body MS_POSITIONING="GridLayout">
 2        <form id="Form1" method="post" runat="server">
 3            <INPUT style="Z-INDEX: 101; LEFT: 64px; POSITION: absolute; TOP: 120px" type="button" value="Button"
 4                onclick="xx()">
 5            <asp:TextBox id="TextBox1" style="Z-INDEX: 102; LEFT: 248px; POSITION: absolute; TOP: 88px" runat="server"
 6                onclick="xx(document.Form1.TextBox1.value)">请输入6位号码</asp:TextBox>
 7            <asp:TextBox id="TextBox2" style="Z-INDEX: 103; LEFT: 176px; POSITION: absolute; TOP: 200px"
 8                runat="server" onclick="xx(document.Form1.TextBox1.value)"></asp:TextBox>
 9        </form>
10        <script language="javascript">
11    function xx(ss)
12    {
13   if(document.Form1.TextBox1.value==ss)
14    {
15    document.Form1.TextBox1.value='';
16    }

17    
18    
19    
20    
21    }

22        </script>
经过高人指点后改为
private void Page_Load(object sender, System.EventArgs e)
  {
   
   
   this.TextBox1.Attributes.Add("onclick","this.focus()");
   this.TextBox1.Attributes.Add("onfocus","checkLogin(this,1,'123')");
   this.TextBox1.Attributes.Add("onblur","checkLogin(this,2,'123')");
                                      // 在此处放置用户代码以初始化页面
  }
function checkLogin(userName,n,co)
 {
 if (n == 0 && userName.value ==co){userName.value="";}
 if (n == 1){
  if(userName.value ==co){userName.value="";}
  
 }
 if (n == 2 && userName.value == ""){userName.value =co;}
}
(感谢石哥的帮助!)
posted on 2006-07-10 10:21  小潘  阅读(776)  评论(0)    收藏  举报