| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1160 人关注过本帖
标题:关于引用了母版页后,怎么在内容页里写javascript的验证表单的代码?
只看楼主 加入收藏
hh_melon
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2007-5-10
收藏
 问题点数:0 回复次数:1 
关于引用了母版页后,怎么在内容页里写javascript的验证表单的代码?

就是我写javascript的表单验证的时候,
因为用到了母版页,
所以就不能像平常一样的那么写了。
<script language="javascript" type="text/javascript">
function Check()
{
if (document.form1.TextBox2.value.length==0)
{
alert("用户号不能为空");
document.form1.TextBox3.value="";
document.form1.TextBox2.focus();
return false;
}
if(isNaN(document.form1.TextBox2.value))
{
alert("用户号必须全部为数字");
document.form1.TextBox2.value="";
document.form1.TextBox3.value="";
document.form1.TextBox2.focus();
return false;
}
if(document.form1.TextBox3.value.length==0)
{
alert("用户的密码不能为空!");
document.form1.TextBox3.focus();
return false;
}
return true;
}
</script>


下面是内容页的开始的部分:
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/ParentMaster.master" CodeFile="ApplerLetter.aspx.cs" Inherits="ApplerLetter" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" ID="register" runat="server">

<script language="javascript" type="text/javascript">
function Check()
{
// if (document.form1.txtUserID.value.length==0)
// {
// alert("用户号不能为空");
// document.form1.txtUserID.value="";
// document.form1.txtUserID.focus();
// return false;
// }
alert("不成功");

return true;
}
</script>

<div>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
用户申请填写信息如下:<br />
<hr style="width: 738px" align="left" color="red" />
<table>
<tr>
<td>用户编号:
</td>
<td>
<asp:TextBox ID="txtUserID" runat="server"></asp:TextBox>
</td>


搜索更多相关主题的帖子: 表单 javascript 代码 验证 
2007-09-24 17:32
zklwzh
Rank: 2
等 级:论坛游民
帖 子:275
专家分:25
注 册:2005-11-16
收藏
得分:0 

前段遇到这个问题,去网上搜了一下。有两种解决办法:1。打开源文件,找到对象,你会发现其ID自动加ct100_母版页的容器名_元素ID。记下它。然后再使用。2。documen.getElementById('<%=对象ID。ClientID%>')进行操作。


2007-09-27 13:54
快速回复:关于引用了母版页后,怎么在内容页里写javascript的验证表单的代码?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011673 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved