Thursday, 27 September 2012

How to get text box value by using java Script



Add A text box to the Page and then

 <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="display()"/>

--JavaScript  Code--

  <script language="javascript" type="text/javascript">
        function display() {
            var text = document.getElementById('<%= TextBox1.ClientID %>').value;
            if (text==="") {
                alert("Please enter Something very carefully");
            }
            else {
                alert("Hi its good");
            }
        }
    </script>

No comments:

Post a Comment