我通过在键盘中输入回车键来验证文本框。验证工作正常,但没有显示 JAlert。但是当我在按钮上调用相同的功能时单击它会在 IE 中显示警报。我对此完全感到困惑。谁能帮我?演示
function isEnterPressed(event) {
var keynum;
if (window.event) {
keynum = event.keyCode;
}else if (event.which) {
keynum = event.which;
}
if(keynum == 13) {
searchSubmit();
}
}
searchSubmit() 也是按钮单击时的函数调用
function searchSubmit()
{
// some valdation
if(!flag)
{
alert('flag'+flag);
jAlert("Enter anyone of the value to search");
return false;
}else{
document.userManagementUsers.action=baseUrl;
document.userManagementUsers.submit();
}
}
alert('flag'+flag) 通过点击回车键显示 jalert 未执行。