你看一下!!谢谢!!
function isValidStr(value){
var mystr=value;
while(mystr.indexOf(" ")!=-1)
mystr=mystr.replace(" ","");
if(mystr.length==0) return false;
return true;
}
function isValidStr(value){
var mystr=value;
while(mystr.indexOf(" ")!=-1)
mystr=mystr.replace(" ","");
if(mystr.length==0) return false;
return true;
}
<script language=JavaScript>
function isValidStr(value)
{
return value.replace(/\s/ig,"")==""?false:true;
}
if(!isValidStr("aa "))
alert("姓名不能为空,请填写!")
else
alert("ok")
if(!isValidStr(" "))
alert("姓名不能为空,请填写!")
else
alert("ok")
</script>
alert("触发了checkInput()事件");
.................
}
在的第一行添加alert("触发了checkInput()事件");测试语句,如果点击提交按钮后没有任何反应说明不是checkInput()函数中的问题,你在<input name="submit" type="button" value=" 提交 " onClick="checkInput()">中找问题吧,onClick="JavaScript:checkInput();" 。