啥也不多说了,上代码!
<form id=frmInput name=frmInput onsubmit="return DisplayCalendar()" action=# method=post>
<IMG style="CURSOR: pointer" onclick=avascript:DisplayCalendar()>
<input name='txtYear'/>
</form>
js文件中
function DisplayCalendar()
{

if (frmInput.txtYear.value<1900||isNaN(frmInput.txtYear.value))
{
alert("请输入合法年份!")
frmInput.txtYear.focus();
return false;
}
} 代码以上
——————————————
说明在IE浏览器中txtYear文本框中不写的话,点击IMG图标会有alert弹出,但在火狐中则没有显示。
请教这是为什么呢??我调试过是火狐会执行DisplayCalendar()这个函数的。但就是没有alert跳出啊???

解决方案 »

  1.   

    onclick=avascript:DisplayCalendar()===》onclick=javascript:DisplayCalendar()
      

  2.   

    最后通过ID给元素赋值,通过name有时候FF会通不过。<form id=frmInput name=frmInput onsubmit="return DisplayCalendar()" action=# method=post>
    <IMG style="CURSOR: pointer" onclick=avascript:DisplayCalendar()>
    <input name='txtYear' id="txtYear"/>
    </form> 
    function DisplayCalendar()
    {if (document.getElementById("txtYear").value <1900||isNaN(document.getElementById("txtYear").value))//不知道这个isNaN()是啥函数?
    {
    alert("请输入合法年份!")
    document.getElementById("txtYear").focus();
    return false;
    }

      

  3.   

    我躲在这里,手握着香槟。
    function DisplayCalendar()