view raw
Monali Monali - 6 months ago 35
ASP.NET (C#) Question

Javascript validation for empty textbox on button click in

I have application with one panel.
Inside that panel i have one image button and

I have written a javascript validation function for textbox which will display alert box for entering some values in
Now this function is not working gave run-time error:

Object required

My code is here:

<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>&nbsp;&nbsp;
<asp:TextBox ID="txtPagingGoto" CssClass="clsTableCellLeft" Width="215px" runat="server" CausesValidation="true"></asp:TextBox>

My Javascript function is:

function fnCheck() {
if ((document.getElementById("txtPagingGoto").value).length == 0) {
alert("The textbox should not be empty");

Please suggest solution for this.

Thanks in advanced.

function fncheck()
        var pgng = document.getElementById("<%=txtPagingGoto.ClientID%>").value.trim();
        if(pgnd == "")
            alert('The textbox should not be empty...');
            return false;