Vignesh Kumar

Vignesh Kumar

  • NA
  • 1k
  • 415.8k

Empty textbox validation on button click

Dec 3 2013 12:48 AM
Hi,

I am using the below piece of javascript for expty textbox validation on button click. It worked when I placed the script inside head tag. And now it doesn't work as I have placed inside asp:content. Can anyone correct me.

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="head">
        <link href="Styles/Style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function validate() {
            if (document.getElementById("txtSearchr").value != "") {
                return true;
            }
            alert('Please enter user details to search!');
            return false;
        }
    </script>
</asp:Content>

Answers (7)