在javascript这么做不行吗?怎么办,在线等,送分
可以建立一个html文件名字为test.html
<html>
<script language="javascript">
function CheckValue(theForm,name,desc){
if(theForm.name.value==""){
alert(desc+"不能为空");
theForm.name.setfocus;
return false;
}
}
function CheckForm(theForm,aaa){
if(!CheckValue(theForm,pwd,"密码"))return false;
return false;
}
</script>
<body>
<form name="post" action="test.html" onsubmit="javascript:return CheckForm(this,1);">
<input type="text" name="pwd" value="">
<input name="Submit" type="submit" value="Submit">
</form>
</body>
</html>
我知道我写的不大对,可是应该怎么写呢,就是要实现把判断封装成一个函数,很急,只要用这种方法不填写pwd则弹出提示就可以了,谢谢