JVerstry JVerstry - 1 month ago 12
HTML Question

How to avoid automatic focus on first input field when popping a HTML form as a JQuery dialog?

I have seen similar questions on SO, including this one, which is old. I read and followed links, but it is unclear whether there is a proper solution to this issue today.

My bottom issue is that I am using HTML's

placeholder="..."
on the input fields. By focusing automatically on the first field, its placeholder is not visible to the user anymore.

EDIT

Here is my HTML code:

<div id='LOGIN_FORM' title="Login">
<form action="">
<input type="text" name="login_id" required="required"
placeholder="Enter user ID" /><br />
<input type="password" name="login_pwd" required="required"
placeholder="Enter password" /><br />
</form>
</div>


Here is my JS code:

$("#login").click(function() {
$("#LOGIN_FORM").dialog({ modal: true }, { buttons: [
{
text: "Ok",
click: function() { $(this).dialog("close"); }
}
] });
});

Answer

A solution is to set tabindex="-1" on ALL input fields to keep HTML placeholders visible.

Comments