Javascript IE10-奇怪表格提交问题

Javascript IE10-奇怪表格提交问题,javascript,html,submit,internet-explorer-10,onfocus,Javascript,Html,Submit,Internet Explorer 10,Onfocus,请参阅下面的代码片段: <!DOCTYPE html> <html> <body> <form name="editProfileForm" method="post" action="profileDataCollection.do"> <input type="text" id="credit-card" name="credit-card" onfocus="unmaskCC(this);" onblur="maskCC(thi

请参阅下面的代码片段:

<!DOCTYPE html>
<html>
<body>
<form name="editProfileForm" method="post" action="profileDataCollection.do">
    <input type="text" id="credit-card" name="credit-card" onfocus="unmaskCC(this);" onblur="maskCC(this);" />
    <input type="hidden" name="ccValue" value=""/>
    <button type="submit">Continue</button>
</form>
<script type="text/javascript">
function unmaskCC(field){
    /*code for unmasking credit card field*/
    alert("unmask called"); /*For demo purpose introduced an alert*/
}
function maskCC(field){
    /*code for masking the credit card field*/
    alert("mask called"); /*For demo purpose introduced an alert*/
}
</script>
</body>
</html>

继续
函数unmaskCC(字段){
/*用于取消屏蔽信用卡字段的代码*/
警报(“取消伪装”);/*出于演示目的引入了警报*/
}
函数maskCC(字段){
/*用于屏蔽信用卡字段的代码*/
警报(“称为掩码”);/*出于演示目的引入了警报*/
}
问题描述:我的一个JSP页面中有上述代码。在InternetExplorer10中呈现此页面时,我看到一个奇怪的问题。当我点击continue按钮(即表单的submit按钮)时,信用卡字段的onfocus会自动触发,并调用函数“unmaskCC”。表格不提交此问题仅在IE10中出现。

我用Google Chrome、Firefox、Safari(台式机、平板电脑、手机)测试了同一页面 无论在哪里,它似乎都运转良好

我最初认为单击submit会导致“事件冒泡”,但这不会发生,因为continue按钮是信用卡字段的同级项

另请注意:我有解决此问题的方法,即更改
按钮类型=“button”
,然后通过onclick javascript提交表单,即。
document.getElementById(“editProfileForm”).submit()它可以正常工作

但我无法理解是什么导致
无法按预期工作

我对IE10的这一特定问题非常着迷。这里的任何帮助都将不胜感激

提前感谢。

这个问题(在IE 11中也可以重现)似乎是由IE中的事件处理问题引起的:当您单击submit按钮时,文本输入字段首先失去焦点,因此它的
onblur
处理程序被触发,导致出现一个模式窗口,在这里IE不知何故丢失了点击输入按钮的信息


如果将
警报更换为
控制台.log
,则不会出现问题。在您的真实代码中,您可能在
onblur
事件处理程序中有一些东西使某些元素或小部件获得焦点,类似地导致IE无法跟踪它在做什么

谢谢你的意见。