Reputation: 5351
When I use Chrome on Android to fill a web form, by pressing the blue "enter" button the browser auto focuses on the next text field. How can I prevent this from happening?
<form action="/action_page.php" method="get">
<input name="text1" value="Bla bla"><br>
<input name="text2" value="Some text"><br>
<input type="submit" value="Submit">
</form>
If anyone is curious why I need this, see here (the answer to that question does not solve my actual problem even though it solved the toy version of it).
Upvotes: 3
Views: 5143
Reputation: 3333
To disable autofocus on all input elements use this.
$(function(){
$('input').blur();
});
To disable autofocus on a particular element, pass the element id as below:
$(function(){
$('input#someid').blur();
});
OR you can use this
$('input').each(function() {
$(this).attr('tabindex', '-1');
});
Upvotes: 1
Reputation: 5947
Simply
<form action="/action_page.php" method="get">
<input name="text1" value="Bla bla" tabindex="-1"><br>
<input name="text2" value="Some text" tabindex="-1"><br>
<input type="submit" value="Submit">
</form>
Upvotes: 1