aspx Tutorial

.NET Articles,jQuery demo, asp.net with jQuery, online tutorial,Jquery, SilverLight, Javascript, asp.net,JSON, MVC,.NET Articles,demo, Web Services, .NET articles, Sharepoint 2010, visual studio 2010,Aamir Hasan,IT, Building Your First Web Application Project
Advertise Here

Toolbar

Get our toolbar!

Advertize



Posted by Aamir Hasan   on Monday, November 1, 2010 Total Views:  

jQuery provide Trim method to remove spaces from start and end of a string

Syntax:

$.trim(string)


Here’s is a solution

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>Remove Spaces from a start and end of a string using jQuery</title>

    <script src="http://code.jquery.com/jquery-1.4.3.min.js" type="text/javascript"></script>

    <script language="javascript">

        $(document).ready(function () {

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

                alert("'" + $.trim($("#<%=TextBox1.ClientID %>").val()) + "'");

                return false;

            });

        });

    </script>

</head>

<body>

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

    <div>

        FullName:

        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

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

    </div>

    </form>

</body>

</html>


Output

Download

Trim.zip (914.00 bytes)

Live Demo

Category: All | jQuery
Protected by Copyscape Online Plagiarism Tool

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5