C# 客户端验证问题

sgliuzhijie 2009-12-17 09:30:25

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">


</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 16px; WIDTH: 648px; POSITION: absolute; TOP: 24px; HEIGHT: 72px"
borderColor="black" cellSpacing="1" cellPadding="1" width="648" border="0">
<TR>
<TD style="WIDTH: 89px; HEIGHT: 28px"><FONT face="宋体"><asp:label id="labBH" runat="server">信息编号</asp:label></FONT></TD>
<TD style="WIDTH: 200px; HEIGHT: 28px"><FONT face="宋体"><asp:textbox id="TBBH" runat="server" Width="104px" ></asp:textbox></FONT></TD>
<TD style="WIDTH: 103px; HEIGHT: 28px"><asp:label id="LabGXRI" runat="server">更新日期</asp:label></TD>
<TD style="HEIGHT: 29px"><FONT face="宋体" id="FONT1">
<asp:textbox id="TbTIME" runat="server" Width="104px"></asp:textbox> </FONT></TD>
</TR>
<TR>
<TD style="height: 30px"><asp:button id="ButTJ" runat="server" Text="提交" onclick="ButTJ_Click" ></asp:button></TD>
<TD style="height: 30px"><asp:button id="ButCZ" runat="server" Text="重置" onclick="ButCZ_Click"></asp:button></TD>
</TR>
</TABLE>
<br />
</form>
<script type="text/javascript"

language="javascript">
function check()
{

if(Form1.TBBH.value=="")
{
alert("请输信息编号")
Form1.TBBH.focus();
return false;
}
}
</script>
</body>
</HTML>




这个验证不起作用??应该怎么写啊?
...全文
174 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
sealyna 2009-12-17
  • 打赏
  • 举报
回复
<TD style="height: 30px"><asp:button id="ButTJ" runat="server" Text="提交" onclick="ButTJ_Click" ></asp:button></TD>
你这段onclick="ButTJ_Click",ButTJ_Click这个应该在后台代码里实现,然后你对于空的验证放在前台来执行是对的,但是你是不知道用什么事件,OnClientClick = "return check()",这样就是先触发OnClientClick事件,再触发onclick事件
zpmissbx 2009-12-17
  • 打赏
  • 举报
回复
把提交换成这个


<input runat="server" type="submit" name="Submit" value="提交" id="Submit1" />
zpmissbx 2009-12-17
  • 打赏
  • 举报
回复

<form id="Form1" method="post" runat="server" onsubmit="return check();">

zpmissbx 2009-12-17
  • 打赏
  • 举报
回复
<form id="Form1" method="post" runat="server" onsubmit="return check();>
luboxy 2009-12-17
  • 打赏
  • 举报
回复
楼上说的对。。。
在你需要的地方调用Check方法啊。。。
yanm7788 2009-12-17
  • 打赏
  • 举报
回复
你的Check方法没调用怎么会验证?怎么调用javascript方法,DIY。
卧_槽 2009-12-17
  • 打赏
  • 举报
回复
想怎么写,就怎么写

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧