I have two input fields. Only one will be visible on the screen at once.
I control which one is visible with variable (Model.Step). If Model.Step = "0", the UserId field shows. If Model.Step = 2, the SecurityAnswer shows and the UserId is hidden.
UserID, already has the autofocus attribute on the input element.
When I press the submit the page will redisplay with the UserId hidden and the SecurityAnswer visible. But the SecurityAnswer does not have focus.
I tried the following:
If I F12 the screen the UserId now does not have the autofocus attribute and the SecurityAnswer does. But the SecurityAnswer still does not have focus.
I assume this is because the IE has already determined what has focus before the attribute gets changed.
Is there a way to make this work with JQuery?
Thanks,
Tom
I control which one is visible with variable (Model.Step). If Model.Step = "0", the UserId field shows. If Model.Step = 2, the SecurityAnswer shows and the UserId is hidden.
UserID, already has the autofocus attribute on the input element.
When I press the submit the page will redisplay with the UserId hidden and the SecurityAnswer visible. But the SecurityAnswer does not have focus.
I tried the following:
Code:
if (currentStep == "2")
{
$("#UserId").removeAttr("autofocus");
$("#SecurityAnswer]").attr("autofocus","autofocus");
}
If I F12 the screen the UserId now does not have the autofocus attribute and the SecurityAnswer does. But the SecurityAnswer still does not have focus.
I assume this is because the IE has already determined what has focus before the attribute gets changed.
Is there a way to make this work with JQuery?
Thanks,
Tom