Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6938385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:29:13+00:00 2026-05-27T12:29:13+00:00

I am trying to move focus to a validation error message using Jquery. By

  • 0

I am trying to move focus to a validation error message using Jquery. By moving focus to the error message a disability screen reader will then read the error message to the user. I am using JQuery Validation:

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

HTML:

@Html.ValidationSummary(true, "Invalid Login! Please correct the errors and try again.")
@using (Html.BeginForm("LogOn", "Account", FormMethod.Post, new { id = "logonForm" }))
{
    @Html.AntiForgeryToken()
    <div>
        <fieldset>
            <legend>Account Information</legend>
            <div class="editor-label">
                @Html.LabelFor(m => m.UserName)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.UserName, new { autocomplete = "off" })
                @Html.ValidationMessageFor(m => m.UserName)
            </div>
            <div class="editor-label">
                @Html.LabelFor(m => m.Password)
            </div>
            <div class="editor-field">
                @Html.PasswordFor(m => m.Password, new { autocomplete = "off" })
                @Html.ValidationMessageFor(m => m.Password)
            </div>
            <p>
                <input type="submit" value="Log On" id="btnLogOn" />
            </p>
        </fieldset>
    </div>
}

JQuery:

$("#logonForm").validate({
            invalidHandler: function (form, validator) {
                var errors = validator.numberOfInvalids();
                alert(errors);
            }
        });

the invalid handler never fires. I never hit the alert statement. Any ideas?

Here is the HTML that is generated from the Razor View Engine:

<form action="/Account/LogOn" id="logonForm" method="post"><input name="__RequestVerificationToken" type="hidden" value="VsOtMMJFUi6nvl38UAqVWsNkteNOaWBRKTUPAHgvn2xRKqBiZDbF//Glbl9IXJUkQssdP7wDk8MKskmN8HYtem+HSDViqRioxEatXs2oqzftBsdhzsrFgZ+akOPb0OZzFMer+A==" />        <div>

            <fieldset>

                <legend>Account Information</legend>

                <div class="editor-label">

                    <label for="UserName">Username</label>

                </div>

                <div class="editor-field">

                    <input autocomplete="off" data-val="true" data-val-regex="Malicious Username" data-val-regex-pattern="^[a-zA-Z0-9\.\@\w-\w_]+$" data-val-required="The Username field is required." id="UserName" name="UserName" type="text" value="" />

                    <span class="field-validation-valid" data-valmsg-for="UserName" data-valmsg-replace="true"></span>

                </div>

                <div class="editor-label">

                    <label for="Password">Password</label>

                </div>

                <div class="editor-field">

                    <input autocomplete="off" data-val="true" data-val-required="The Password field is required." id="Password" name="Password" type="password" />

                    <span class="field-validation-valid" data-valmsg-for="Password" data-valmsg-replace="true"></span>

                </div>

                <p>

                    <input type="submit" value="Log On" id="btnLogOn" />

                </p>

            </fieldset>

        </div>

</form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:29:13+00:00Added an answer on May 27, 2026 at 12:29 pm

    It doesn’t look like you have any required fields. You can either add them to the rules or add a “required” class to the fields.

    Also, it looks like you are mixing ASP.NET validation with jQuery validate; MS supplies both but you only use one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to move X number of rows down in a table using jQuery...
Im trying to move the scroll of a div with jquery, but i dont
I'm trying move a window partially off the top of the screen. However, Windows'
Im trying to move a system from using morbid to rabbitmq, but I cannot
Im trying to move a UIImage from the top of the screen to the
I'm trying to map alt left/right to move the cursor focus between the file
I'm trying to move my database.mdf file from a development environment to a SQL
Actually I am trying to move some box alternatively with in another box. I
I'm trying to move some table storage in Azure from local storage to the
I'm trying to move my game development into the third dimension, but I'm having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.