2015-09-05 106 views
-1

我试过多个脚本和方法清除输入字段,一旦输入命中。我有一个脚本工作,虽然它太快,所以邮件永远不会提交。 我想知道是否有什么办法可以延缓它?HTML输入在输入不清除字段

这是我使用的脚本,虽然它提交太快当你点击提交按钮

\t \t <input class="chat-window-message keydown" name="message" id="InputMessage" type="text" autocomplete="off" placeholder="....." onload="self.focus();" autofocus required /> 
 
\t \t \t <script> 
 
document.getElementById('InputMessage').addEventListener('change',function(){ 
 
    //somehow search for the term here 
 
    //remove text 
 
    document.getElementById('InputMessage').value=''; 
 
},false); \t 
 
</script>

+0

你究竟想要什么?你可以说得更详细点吗 ? –

+0

我需要延迟一秒的功能,以便表单有机会提交 –

+0

您可以使用'setTimeout'函数延迟您想要的任何js代码 –

回答

0

写JS函数调用。在此功能中,请在表格上拨打submit(),然后清除该字段(使用您的代码或reset()方法)。