我有一个asp.net应用程序,其中包含一个面板。
在该面板内,我有一个图像按钮和一个文本框
。
我编写了一个JavaScript验证函数,用于对文本框
进行验证,如果没有输入值,则会显示警告框。
现在此函数无法工作并报运行时错误:
对象必需
我的代码如下:
<asp:Panel ID="pnlTop" runat="server">
<tr height="35px" valign="top">
<td align="right" valign="middle" colspan="2" height="50">
<asp:ImageButton ID="imgbtnGOTO" runat="server" ToolTip="View Specific Record" BorderWidth="0"
ImageAlign="AbsMiddle" OnClientClick="javascript:return fnCheck()"></asp:ImageButton>
<asp:TextBox ID="txtPagingGoto" CssClass="clsTableCellLeft" Width="215px" runat="server" CausesValidation="true"></asp:TextBox>
</td>
</tr>
</asp:Panel>
我的Javascript函数是:
function fnCheck() {
if ((document.getElementById("txtPagingGoto").value).length == 0) {
alert("The textbox should not be empty");
}
}
请为此提供解决方案。
ImageButton
中的OnClientClick="fnCheck"
。 - user2660112