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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:34:29+00:00 2026-06-15T06:34:29+00:00

I am using MVC3 and unobstrusive validation. On certain occasions I want to submit

  • 0

I am using MVC3 and unobstrusive validation. On certain occasions I want to submit a form even if the form is incomplete providing two fields are selected. The JavaScript I am using is as follows:

$('#form_section11').submit(function () {
        //event.preventDefault(); //stops form from submitting immediately 

        var validatorSection11 = $('#form_section11').validate();

        if (!$(this).valid()) {
            // or family name and date of birth
            var FamilyNameExists = true;
            var DateOfBirthExists = true;                

            if (validatorSection11.errorMap["FamilyName"]) { FamilyNameExists = false; }
            if (validatorSection11.errorMap["DateOfBirth"]) { DateOfBirthExists = false; }                

            // show the partial save rules
            $('#ParitalSaveIntructions').show();
            // show the partial save checkbox
            if (FamilyNameExists && DateOfBirthExists) {

                $("#AgreePartialSave").show();

                if ($("#PartialSave").is(':checked')) {
                    //  partial save has been requested
                    return true;    //// <- save not happening, INCORRECT action
                }
                // clear perinatalWomanView_PartialSave
                $("#PartialSave").removeAttr('checked');
            }
            return false;   // <- save not happening, correct action
        } 
        return true;    // <- save happens, correct action
    });

The user is presented with a checkbox to confirm incomplete submission. I’ve indicated where the JavaScript works and where it fails.

I’ve also added

var validatorSection11 = $('#form_section11').validate(
            {
                onsubmit: false
            }
        );

This has no effect. My questions are:

Why is the original return true not functioning?
Am I using the onsubmit: false correctly?
Is there a better way of doing this?

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-15T06:34:30+00:00Added an answer on June 15, 2026 at 6:34 am

    Try using a variable (save) instead of multiple return statements:

    $('#form_section11').submit(function (e) {
        'use strict';
        var self = $(this),
            save = false,
            FamilyNameExists = true,
            DateOfBirthExists = true,
            validatorSection11 = self.validate();
        if (!self.valid()) {
            // or family name and date of birth
            FamilyNameExists = true;
            DateOfBirthExists = true;
            if (validatorSection11.errorMap["FamilyName"]) {
                FamilyNameExists = false;
            }
            if (validatorSection11.errorMap["DateOfBirth"]) {
                DateOfBirthExists = false;
            }
            // show the partial save rules
            $('#ParitalSaveIntructions').show(); // should this be "Parital" or "Partial"
            // show the partial save checkbox
            if (FamilyNameExists && DateOfBirthExists) {
                $("#AgreePartialSave").show();
                //if ($("#PartialSave").is(':checked')) { // Comment in answer
                //    // partial save has been requested
                //    save = true;
                //}
                save = $("#PartialSave").is(':checked');
                // clear perinatalWomanView_PartialSave
                $("#PartialSave").removeAttr('checked');
            }
            //save = false; //This was overriding the `save = true` above.
        }
        if (!save) {
            e.preventDefault(); // stops form from submitting immediately 
        }
        return save;
    });
    

    Also, at the section “Comment in answer”, this section will likely only execute after the form has been resubmitted because the following would have to happen:

    1. $("#AgreePartialSave").show(); has to execute and show the section.
    2. The user has to put a check in $("#PartialSave") for $("#PartialSave").is(':checked') to return true.
    3. The $('#form_section11').submit() has to fire again for that section of the handler to evaluate.

    If there is a different button that the user has to click to do a partial save, you’ll likely want to move that whole section into that button handler.

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

Sidebar

Related Questions

I am using MVC3, EF Model first. I have a form with two DropDownList
I need to enable the validation of hidden fields using ASP.net MVC3 unobtrusive validation.
I'm writing an MVC3 site, and I'm using JQuery unobtrusive validation to validate my
I just created a sample MVC3 application to learn validation. It is using DataAnnotations.
I've got some dynamically inserted form fields on a page in an MVC3 project.
I have just finished up an online form using ASP.net MVC3 with unobtrusive. I
I am using a form to upload a file. I want only PDF files
I am using MVC 3 + unobstrusive validation. For some field I am using
I'm using MVC3 with unobtrusive validation. I have a field that the user is
I'm using DataAnnotations to validate my input fields on a MVC3 application. I'm using

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.