Note that there are some explanatory texts on larger screens.

plurals
  1. POSelect List Focus on invalidate in MVC 3 with Jquery Validation
    primarykey
    data
    text
    <p>In my MVC3 app on invalidate form, focus is not set on the first select list (if the select list data is empty/invalid). Select list is invalidated but focus is not set. In case of input type i.e textbox, radio etc it works fine. I wonder what's missing??</p> <pre><code>Cool...here comes the model and view... **Model** public class RegisterModel { [Remote("CheckDuplicateUserName","Account")] [Display(Name = "User name")] [Required(ErrorMessage = "This field is required.")] [StringLength(30)] public string UserName { get; set; } [DataType(DataType.EmailAddress)] [Display(Name = "Email address")] [Remote("CheckDuplicateEmail", "Account")] [Required(ErrorMessage = "This field is required.")] public string Email { get; set; } [ValidatePasswordLength] [DataType(DataType.Password)] [Display(Name = "Password")] [Required(ErrorMessage = "This field is required.")] [StringLength(30)] public string Password { get; set; } [DataType(DataType.Password)] [Display(Name = "Confirm password")] [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] [StringLength(30)] public string ConfirmPassword { get; set; } //additional fields [Display(Name = "Name")] [Required(ErrorMessage = "This field is required.")] [StringLength(30)] public string Name { get; set; } [Display(Name = "Address")] [StringLength(100)] public string Address { get; set; } [Display(Name = "City")] [Required(ErrorMessage = "This field is required.")] public string City { get; set; } } **View** @model MyShowCase.Models.RegisterModel @{ ViewBag.Title = "Register"; } &lt;script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"&gt;&lt;/script&gt; @using (Html.BeginForm("Register","Account")) { @Html.ValidationSummary(true, "Account creation was unsuccessful. Please correct the errors and try again.") &lt;div id="register"&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(m =&gt; m.UserName) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.TextBoxFor(m =&gt; m.UserName) * @Html.ValidationMessageFor(m =&gt; m.UserName) &lt;span class="instruction"&gt; username should be alphanumeric without any special characters.&lt;/span&gt; &lt;/div&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(m =&gt; m.Password) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.PasswordFor(m =&gt; m.Password) * @Html.ValidationMessageFor(m =&gt; m.Password) &lt;span class="instruction"&gt; Passwords are required to be a minimum of @ViewBag.PasswordLength characters in length.&lt;/span&gt; &lt;/div&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(m =&gt; m.ConfirmPassword) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.PasswordFor(m =&gt; m.ConfirmPassword) * @Html.ValidationMessageFor(m =&gt; m.ConfirmPassword) &lt;/div&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(m =&gt; m.Name) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.TextBoxFor(m =&gt; m.Name) * @Html.ValidationMessageFor(m =&gt; m.Name) &lt;span class="instruction"&gt; Specify your Full Name here.&lt;/span&gt; &lt;/div&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(m =&gt; m.City) &lt;/div&gt; &lt;div class="editor-field"&gt; &lt;select id="City" name="City"&gt; &lt;option value="" selected="selected"&gt;&lt;/option&gt; &lt;option &gt;Dubai&lt;/option&gt; &lt;option &gt;Abu Dhabi&lt;/option&gt; &lt;/select&gt; * @Html.ValidationMessageFor(m =&gt; m.City) &lt;/div&gt; &lt;/div&gt; } Here is all what i have, the problem is that focus is not set on "City" Dropdown if City is not selected. Its validated but the focus in not set.... web.config &lt;appSettings&gt; &lt;add key="ClientValidationEnabled" value="true" /&gt; &lt;add key="UnobtrusiveJavaScriptEnabled" value="true" /&gt; &lt;/appSettings&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload