首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

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

2012-12-30 
如下的JS IE下能使用,google、火狐下面却不能使用。script typetext/javascriptfunction validate_requ

如下的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>

热点排行
Bad Request.