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"> |
|