Thursday, August 23, 2007

Remove Space At Beginning Of The String Using Regular Expression (Left Trim)

<html>
<head>
<script language="javascript">
function Right_Trim()
{
var str = document.getElementById('txt1').value;
str = str.replace(/^\s+/g,'');
document.getElementById('txt1').value = str;
document.getElementById('txt1').focus();
}
</script>
</head>
<body>
<input type='text' id='txt1' value='                 Click To Check' />
<input type='button' id='bt1' value='Remove Space At Beginning Of The String' onclick='Right_Trim();' />
</body>
</html>



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.