Sunday, 6 October 2013

how to trim text box value in javascript in .Net

    // implementing a trim function for strings in javascript
            <script language="JavaScript" type="text/javascript">
            <!--
            String.prototype.trim = function () {
            return this.replace(/^\s*/, "").replace(/\s*$/, "");
           }
           </script>

  <asp:TextBox runat="server" ID="abdc" onkeyup ="OnChange(this)" onblur="ShowAvailability()" onchange="this.value=this.value.trim()"></asp:TextBox>

No comments:

Post a Comment