日期:2014-05-16  浏览次数:20345 次

如下的JS IE下能使用,google、火狐下面却不能使用。

<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(state,"请选择审核状态!")==false)
    {state.focus();return false}
  }
}
</script> 

------解决方案--------------------
没有写value属性,gg,ff会将显示的text作为value

<select id="sel1"><option>默认值</option></select>
<script type="text/javascript">
    window.onload = function () {
        alert(document.getElementById('sel1').value)
    }
</script>