Как отключить отправку из input по нажатию enter?
Вот мой input
<input type="text" class="form-control" id="txtCommand"> мне нужно чтоб при нажатии в поле enter нечего не происходило. Помогите пожалуйста! |
txtCommand.form.onsubmit = function() { return false; }; |
отправляет
|
CrazzyBerg,
<!DOCTYPE HTML> <html> <head> <title>Untitled</title> <meta charset="utf-8"> </head> <body> <form action="http://" > <input type="text" class="form-control" id="txtCommand" > <input name="" type="submit" value="Отправить"> </form> <script> var fn = function(a) { var b; document.getElementById(a).onkeypress = function() { b = event.keyCode }; document.forms[0].onsubmit = function() { var a = 13 != b; b = ""; return a } }("txtCommand"); </script> </body> </html> |
<form action='http://'onsubmit="alert('submit!');return false"> <input type="text" class="form-control" id="txtCommand"> <br> <input type="submit" value="Отправить"> </form> ай блин тебе надо только чтобы при нажатии enter форма не отправлялась а при клике должна? тогда Вон у Рони удачное решение))) |
DynkanMaclaud,
и как теперь форму отправить? |
Цитата:
|
Цитата:
|
Часовой пояс GMT +3, время: 11:30. |