7
Answers

Empty textbox validation on button click

Ask a question
Vignesh Kumar

Vignesh Kumar

10y
1.9k
1
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)