<html>
<head>
<title>Zvonko *</title>
<script language=“JavaScript” type="text/javascript">
String.prototype.Trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "").replace(/\s+/g,' ');
}
// trim blank space at the beginning
String.prototype.LTrim = function()
{
return this.replace(/(^\s*)/g, "").replace(/\s+/g,' ');
}
// trim blank space at the end
String.prototype.RTrim = function()
{
return this.replace(/(\s*$)/g, "").replace(/\s+/g,' ');
}
function Test()
{
var s = new String(" Hello, world! ");
s = s.Trim();
alert("#" + s + "#");
}
</script>
</head>
<body>
<form name="form1">
<input type="button" name="button1" value="Test" onclick="Test();" />
</form>
</body>
</html>
|