0
提交按鈕,通過輸入我有這一塊的HTML代碼:的JavaScript的onsubmit無需通過鍵盤
<form id="cambia_stato" method="get" action="">
<input type="text" name="stato" id="frase_stato" value=""
onclick="this.value='';" onblur="setMessaggio()" maxlength="255"
/>
</form>
,我要檢查「stato」場對提交的值。 我嘗試了兩種方式: 使用的onsubmit不按Enter鍵觸發:
<!-- nothing happens with the following -->
<form id="cambia_stato" method="get" action="" onsubmit="myFunc()">
所以,我想每一個鍵被按下時檢查輸入,改變輸入屬性添加onkeypressed事件:
<!-- nothing happens with the following -->
<input type="text" name="stato" id="frase_stato" value=""
onclick="this.value='';" onblur="setMessaggio()" maxlength="255"
onkeypressed="myFunc()" />
就目前來說,函數myFunc的()被定義爲如下:
function myFunc()
{
alert('test');
}
我是否在某處出錯或需要提交按鈕?
不是真的,雖然感謝 – sowdust
是的。看看其他一些答案和http://stackoverflow.com/search?q=submit+enter – mplungjan
你是對的,對此抱歉。我在這裏很新,我將學習如何更好地搜索 – sowdust