Javascript中是没有Trim这个函数的,但我们可以为其定义一个:<input type=text size=8 name=test>
<input type=button value=check onclick=check1()>
<script language="Javascript"><!--
var da = document.all;
String.prototype.Trim = function(){return this.replace(/(^\s*)|(\s*$)/g, "");} //定义Trim
function check1(){
  if (da.test.value.Trim.length==0)alert("对不起!输入框不能为空!");
  }
//--></script>