换成vbscript <script language="vbscript"> function checkForm() if trim(document.ping.subject.value)="" then msgbox("请输入标题!") checkForm=false end if if trim(document.ping.content.value)="" then msgbox("请输入内容!") checkForm=false end if return true end function </script>
String.prototype.trim = function()
{
return this.replace(/(^[\s]*)|([\s]*$)/g, "");
}
然后判断
if(document.ping.subject.value.trim()=="")
if(document.ping.content.value.trim()=="")
<script language="vbscript">
function checkForm()
if trim(document.ping.subject.value)="" then
msgbox("请输入标题!")
checkForm=false
end if
if trim(document.ping.content.value)="" then
msgbox("请输入内容!")
checkForm=false
end if
return true
end function
</script>