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 8664767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:19:23+00:00 2026-06-12T17:19:23+00:00

I am using an Ajax.BeginForm with unobtrusive validation. I want to give the user

  • 0

I am using an Ajax.BeginForm with unobtrusive validation. I want to give the user the option to save the data with a minimum number of validated fields (which might be zero) but allow some required fields to be saved when empty.

I think my requirements are:

  • add an event handler to the submit button
  • perform the validation manually
  • identify which fields have failed validation because they are empty
  • identify which fields have failed validation the data is in error

I can catch the submit event and validate the form by adding the following at “document ready”

$(document).ready(function () {

    $('#submit-11').click(function () {
        if (!$("#form0").valid()) {
            alert("woops");
            return false;
        }
        return true;
    });

My problem now is how to identify which fields have failed validation and the reason for failing.

I can find nothing on Google (although that may be a function of my search skills rather than the problem.)

Thanks in advance.

  • 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-06-12T17:19:25+00:00Added an answer on June 12, 2026 at 5:19 pm

    have you tried

    event.preventDefault();

    just after the submit click?
    http://api.jquery.com/event.preventDefault/

    Now regarding your larger question. I think you can do all of that with jquery
    here’s an example

    $(document).ready(function () {
        //form validation rules, including custom rules you'd like
        $("#form").validate({
            rules: {
                fieldOne: { required: true },
                fieldTwo: { required: function () { /*custom validation*/return true; } }
            },
            messages: {
                fieldOne: { required: "error" },
                fieldTwo: { required: "error" }
            }
        });
        //handle submit click
        $("#btnSubmit").click(function (event) {
            event.preventDefault(); //stops form from submitting immediately 
            if ($("#form").valid()) { //perform validation 
                //submit your data if valid
                $.post("/your/action", $form.serialize(), function (data) { 
                    //do something with the result
                });
            }
        });
    
    });
    

    UPDATE:
    So maybe you should be doing this, when you add the validate handler to the form you can implement the submitHandler and the invalidHandler.
    Now what you really should be looking at is the invalidHandler

            $(document).ready(function(){
                $("#form").validate({
                    rules : {
                        field : {required : true}                   
                    },
                    messages : {
                        field : {required : ""}                 
                    },
                    submitHandler: function(form) {                     
                        form.submit(); //if all is good
                    }, 
                    invalidHandler: function(form, validator){
                        console.log(validator.errorList); //if something went wrong
                    }
                });
    

    this function receives the validator which in turns has the errorList containing all the fields (and messages) that failed.
    Test this code with chrome’s developer tools, for instance, and you’ll see what’s in the errorList.

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

Sidebar

Related Questions

I have the following code in MVC 3.0 with unobtrusive JavaScript enabled. using (Ajax.BeginForm(search,
In the following code, I'm using Ajax.BeginForm to post data to the action asynchronously.
I am using Ajax.Begin Form in my MVC 3 + Razor application using (Ajax.BeginForm(ActionName,
Code: <% using (Ajax.BeginForm(GetResourcesByProject, CreateRequest, new AjaxOptions { UpdateTargetId = ResourceListDiv})) { Response.Write(Html.DropDownList(SelectProject, Model.ProjectList,
I have form in my page, I am using ajax.beginform(). Inside this form I
I have a mvc2 application with a view like this <% using (Ajax.BeginForm(UserApprove, new
I have the following view definition in my asp.net mvc website: <% Using Ajax.BeginForm(UsrCtlChangePassword,
I'm using MVC and AJax.BeginForm to do some ajax updating of my page. The
I am using Ajax to post the comments of the website. No the user
I am using ajax jquery to send data to php, as data I am

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.