我有一个面板的asp.net应用程序。 在那个面板里面我有一个图像按钮和textbox
。 我已经为文本框写了一个javascript验证函数,它将显示用于在textbox
中输入一些值的警报框。 现在,这个功能不能正常工作了运行时错误:在asp.net按钮点击空文本框的Javascript验证
Object required
我的代码是在这里:
<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");
}
}
请建议此解决方案。
谢谢先进。
只需修改'的OnClientClick = “fnCheck”''中ImageButton' – 2013-10-08 10:50:16