2015-09-05 104 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()方法)。