Home
Do You Help Users By Selecting A Default Field
  v1.0 Posted at 12/12/2012 2:46 PM by Gerard Beckerleg
​Help your users by setting the default field when your MVC WebSite loads.​​
By selecting a default field for your users when a page loads you can improve the usability of your web site by reducing the amount of steps needed to perform a task.

Here is a way to do this with MVC 3 and Razor:
1. Add a div with a class around the field you want to set focus on

<div class="focus">
    @Html.EditorFor(model => model.FirstName)​
    @Html
    @Html.ValidationMessageFor(model => model.FirstName)
</div>

2. Then use jQuery to select the class and set focus​:

$(function() {
    $('.focus :input').focus();
});

Related rules

    Do you feel this rule needs an update?

    If you want to be notified when this rule is updated, please enter your email address:

    Comments: