改成这样:
<html><head>
<title>test</title>
</head><body><script>
function checkIfFilled() {
    if (document.forms[0].name.value=='') { // 你引用的password 不存在 应该是 pass        window.alert('名字未输入!');
        return(false);
        }
    if (document.forms[0].pass.value=='') { //你引用的yourname 不存在 应该是 name        window.alert('密码未输入!');
        return(false);
        }
    return(true);
}
</script>
<form action="" method="post" onsubmit="return(checkIfFilled());">
<fieldset>
<legend>认证</legend>
<dl>
<dt>名字</dt>
<dd><input type="text" name="name" size="24" /></dd>
<dt>密码</dt>
<dd><input type="password" name="pass" size="24" /></dd>
</dl>
<ul>
<li><input type="submit" value="提交" /></li>
</ul>
</fieldset>
</form></body></html>