我正在进行简单的Javascript表单验证,并且无法访问表单中的元素。似乎命令:
document.forms["myForm"]["un"].value;
适用于Explorer,但不适用于Firefox。我正在处理的表格是:
<form name = "myForm" onsubmit="check()" method="POST">
User Name:<br><input type="text" name = "un"><br/>
Password:<br><input type="password" name = "pw"><br/>
Confirm Password:<br><input type="password" name = "cpw"><br/>
Email:<br><input type = "text" name = "em"><br/>
<input type = "submit" id = "sub" value="submit">
让js验证:
<script type = "text/javascript">
var user = document.forms["myForm"]["un"].value;
alert(user);
</script>
答案 0 :(得分:-1)