Javascript 检测web表单中的键笔划

Javascript 检测web表单中的键笔划,javascript,asp.net,Javascript,Asp.net,我有一个文本模式设置为“多”的web表单文本框。最近一个功能停止工作,我不知道发生了什么。当用户连续两次按[Return]键时,webform将通过客户端javascript触发submit按钮事件。像这样: function postPage() { var inputString = document.getElementById("Search1_AccordionPane2_content_txtSearchText").value; if (inputS

我有一个文本模式设置为“多”的web表单文本框。最近一个功能停止工作,我不知道发生了什么。当用户连续两次按[Return]键时,webform将通过客户端javascript触发submit按钮事件。像这样:

function postPage() {       
    var inputString = document.getElementById("Search1_AccordionPane2_content_txtSearchText").value;

    if (inputString.match(/(\r\n){2,}/)) {
        document.getElementById("Search1_AccordionPane2_content_txtSearchText").click();
    }
}
代码没有改变,我们的用户在W7上使用IE8,我怀疑这在进入W7或IE8后停止工作。此外,浏览器设置受我不控制的组策略限制。你知道从哪里开始调试这个吗

谢谢,


Risho

尝试使用以下
使
\r
可选:
/(\r?\n){2,}/
,以防IE8使用单个
\n
而不是
\r\n
作为行终止符,事件侦听器是什么?不幸的是,我无法访问IE8或W7来尝试其他建议。可能尝试类似于
alert(inputString.replace('\n','[n]')。replace('\r','[r]')
为了找出字符串中应该查找的内容(假设匹配是失败的部分),我刚刚在WinXP上的IE8中对其进行了测试(对不起,我猜我撒谎了),匹配成功了,您可以发布事件处理程序代码吗?控件位于.ascx文件中,如下所示:。javascript函数:function postPage(){var inputString=document.getElementById(“Search1_AccordionPane2_content_txtSearchText”).value;if(inputString.match(/(\r\n){2,}/){document.getElementById(“Search1_AccordionPane2_content_txtSearchText”)。单击()}愚蠢的问题:asp是否会自动将文本框ID从
txtSearchText
更新为
Search1\u acordionpane2\u content\u txtSearchText
?因为否则您的getElementById将不匹配Search1\u AccordionPane2\u content\u txtSearchText最初是从呈现的页面“查看源”获取的。