aspx Tutorial

NET Articles,jQuery demo, with jQuery, online tutorial,Jquery, SilverLight, Javascript,,JSON, MVC,.NET Articles,demo, Web Services,
Advertise Here


Get our toolbar!


Posted by Aamir Hasan   on Saturday, August 20, 2011 Total Views:  

In this example, we have a button and input text boxes in  the form, we will clear all text boxes  when user type any text in the text boxes it can be clear through clear form button.

Lets see the example


<html xmlns="">

<head runat="server">


    <script type="text/javascript" src=""></script>

    <script type="text/javascript">

        $(function () {

            $("#<%=Button1.ClientID %>").click(function (e) {

                $("form input")

                .not(':reset, :submit, :hidden, :button')


                return false;






    <form id="form1" runat="server">



            Name:<asp:TextBox ID="tbName" runat="server"></asp:TextBox></p>


            Email Address:<asp:TextBox ID="tbemail" runat="server"></asp:TextBox></p>



            <asp:TextBox ID="tbbirth" runat="server"></asp:TextBox></p>


            Alternative Email Address<asp:TextBox ID="tbAltEmail" runat="server"></asp:TextBox></p>


            <asp:Button ID="Button1" runat="server" Text="Clear form" />

            <asp:Button ID="Button2" runat="server" Text="Submit" />





        Author:Aamir Hasan

        <br />

        <a href="">Free online tutorial</a>




As you can see, we have used val() function to clear the text from all boxes in the form

Note: Make sure that all input textboxes should be within the form tag.


Clear-textbox.aspx (1.68 kb)

See live demo

Category: All | jQuery
Protected by Copyscape Online Plagiarism Tool

Add comment

  Country flag

  • Comment
  • Preview

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5