We help IT Professionals succeed at work.
Get Started

On Form Submit - sending true/false not working for Chrome or IE8-

1,130 Views
Last Modified: 2016-02-25
I have a C# .Net MVC web site that I have stood up. The site is being displayed within an IFrame in a classic ASP site. This is being done because we are in the process of converting the site over to a .Net 4.5 solution, but needed a particular piece of functionality completed.

Problem
1) The user fills out a form
2) The click the submit button
3) Validation occurs using JavaScript (and jQuery in particular). If validation is successful, then return true, else return false.

If false, then the user is supposed to stay on the page and error messages are revealed.
If true, then the user is supposed to get a greyed out screen while the page is processing and sending to the server. It will then transition over to the new server

What is happening is the page is getting stuck and not transitioning to the next page when the result is true.

This happens in Chrome and versions of Internet Explorer 8 and less.  

I have tried to code on both the form object ($(document).on("submit", "#PartnerCartForm", function(){});) as well as on the button with the same results.

jQuery Code:
   $(document).on("click", '#submitOrder', function () {
        var isValid = false;

        // Step 1. Disable Submit button
        $(this).prop('disabled', true);
        $(".bhiErrorInput").css({ 'display': 'none' });

        // Step 2. Update text on submit Button
        $(this).val("Processing...");

        // Step 3. Disable all form fields
        $("input[type=text]").prop('disabled', true);
        $("select").prop('disabled', true);

        // Step 4. Grey out the Screen
        $('#thickBoxGreyScreen').css({ opacity: 0.7, 'width': $(document).width(), 'height': $(document).height() });
        $('body').css({ 'overflow': 'hidden' });
        $('#thickBoxInfoPane').css({ 'display': 'block' });

        isValid = validateOrder();    // set of methods that return true or false


        if (!isValid) {
            $('#thickBoxGreyScreen').css({ 'display' : 'none' })
            $('#thickBoxInfoPane').css({ 'display': 'none' })

            $(this).val("Submit Order");
            $("input[type=text]").prop('disabled', false);
            $("select").prop('disabled', false);
            $(this).prop('disabled', false);
        }
        else {
            $("input[type=text]").prop('disabled', false);
            $("select").prop('disabled', false);
        }
        event.returnValue = isValid;
        return isValid;
    });     // end of $(document).on("click", '#submitOrder', function () {

Open in new window


HTML

        @using (Html.BeginForm("PartnerCartSubmit", "Partner", FormMethod.Post, new { id = "PartnerCartForm" }))
        {
            @Html.AntiForgeryToken()
            if (!String.IsNullOrEmpty(ViewBag.ErrorMessage))
            {
            <div class="bhiErrorBar">
                @Html.Raw(ViewBag.ErrorMessage)
            </div>
            }
    <h1 class="standardText">Addresses</h1>
            <div id="bhiAddressDiv">
                <div class="bhiAddressDetail">
...
...   // HTML of the form removed for simplification. 
...
            </div>
            <input type="submit" value="Submit Order" id="submitOrder" />

            <div class="clear"></div>

            <div id="thickBoxInfoPane">
                <p>Your payment is being processed...</p>
            </div>
            <div id="thickBoxGreyScreen"></div>

        }

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 2 Answers and 9 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE