初学JS脚本验证表单,点击提交后没有反映!朋友们帮看下是那里有问题:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New PHP File</title>
<script language=javascript>
function checkform(){
if(form.user.value=""){
alert("请输入用户名!");
form.user.focus();
return false;
}
if(form.title.value=""){
alert("请输入主师!");
form.title.focus();
return false;
}
if(form.content.value=""){
alert("请输入内容!");
form.content.focus();
return false;
}
}
</script>
</head>
<body>
<form name="form" action="add.php" method="post" onsubmit="return checkform();">
username:<input name="user" type="text" /><br />
title:<input type="text" name="title" /><br />
content:<textarea rows="3" cols="40" name="content"></textarea><br />
<input type="submit" value="提交" name="submit" />
<input type="reset" name="重置" />
</form>
</body>
</html>