javascript中with(thisform)是什么意思解决思路

javascript中with(thisform)是什么意思javascript中with(thisform)是什么意思?htmlheadscript type

javascript中with(thisform)是什么意思
javascript中with(thisform)是什么意思?
<html>
<head>
<script type="text/javascript">

function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {alert(alerttxt);return false}
  else {return true}
  }
}

function validate_form(thisform)
{
with (thisform)
  {
  if (validate_required(email,"Email must be filled out!")==false)
    {email.focus();return false}
  }
}
</script>
</head>

<body>
<form action="submitpage.htm" onsubmit="return validate_form(this)" method="post">
Email: <input type="text" name="email" size="30">
<input type="submit" value="Submit"> 
</form>
</body>

</html>
[解决办法]


[解决办法]
thisform.email
你本来要这么写引用email
加了with就不用了
直接  email就可以了

[解决办法]
with就是设定作用域。
例子中在with(thisform){}中,作用域为thisform, email等价于 thisform.email
不过不建议这样使用