Wednesday, August 22, 2007

Removing The White Space In The String At The End Using Regular Expression (Right Trim)

<script language="javascript">
function Left_Trim()
var str = document.getElementById('txt1').value;
alert(str.length);// Alert To Show The Length Of The String Before Removing White Space
str = str.replace(/\s+$/g,'');
alert(str.length); // Alert To Show The Length Of The String After Removing White Space
document.getElementById('txt1').value = str;
<input type='text' id='txt1' value='Click To Check ' /> <input type='button' id='bt1' value='Remove Space At End Of The String' onclick='Left_Trim();' />

No comments:

Creative Commons License
Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.