<html>
<head>
<script>
function ccc(str){
alert(str.value.length);
alert(str.value.replace(/(^\s*)|(\s*$)/g, "").length);
return str.value.replace(/(^\s*)|(\s*$)/g, "");
}
</script>
</head>
<body>
<input type="text" value=" jacklucy " οnclick="ccc(this);">
</body>
</html>
//---------------------------------------------------------------------
function mytrim(str){ //删除左右两端的空格
return str.replace(/(^\s*)|(\s*$)/g, "");
}