u can remove space by using function trim which is not in javascript

Deepak Ghule replied to Raj Kumar at 03-Jul-08 09:07

u can remove space by using function trim which is not in javascript

 

 

 


  function trim(str, chars)
  {
      return ltrim(rtrim(str, chars), chars);
  }

  

  function ltrim(str, chars)
  {
      chars = chars || "\\s";
      return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
  }

  

  function rtrim(str, chars)
  {
      chars = chars || "\\s";
      return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
  }
  
  
  
     function Validate()
     {
       if (trim(document.getElementById("txtReason").value,' ')=="")
       {
       alert("Please enter the cancellation reason");
       return false;
       }
       return true;
      
     }

 


html for page will be

<asp:TextBox id="txtReason" Runat="server" onkeypress="doKeypress(this);" onbeforepaste="doBeforePaste(this);"
onpaste="doPaste(this);" Width="256px" MaxLength="200" TextMode="MultiLine" Height="98px"></asp:TextBox>
<asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server" CssClass="errormessage" ForeColor=" "
ErrorMessage="Please enter reason" Display="Dynamic" ControlToValidate="txtReason">


Click here to sign in and reply. You could earn money via our $500 contest just for being helpful.
  How to delete blank space in text file in Java script - Raj Kumar  03-Jul-08 08:59 8:59:40 AM
      u can remove space by using function trim which is not in javascript - Deepak Ghule  03-Jul-08 09:07 9:07:11 AM
      Try this - Jason S  03-Jul-08 09:42 9:42:12 AM
      Reply - alice johnson  03-Jul-08 01:13 1:13:55 PM
      See this to remove blank space - Sujit Patil  04-Jul-08 12:02 12:02:41 AM
      Reading File with JavaScript - kalit sikka  04-Jul-08 01:28 1:28:47 AM
      Try this - santhosh kumar  04-Jul-08 02:08 2:08:52 AM
View Posts