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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:37:26+00:00 2026-06-11T06:37:26+00:00

I have a form validation run when the submit button is selected but i

  • 0

I have a form validation run when the submit button is selected but i do not want the default submit function to run. Instead i want to run an ajax post code to store the data in the form along with post the data from server side.

I am having trouble finding where to cancel the default submit and add in the ajax code.

Here is the validate code i have

    $("#formEnroll").validate({
    errorElement:"p",
    submitHandler: function(form) {
            var phoneNumber = form.day_phone.value;             
            var phoneParts  = phoneNumber.split("-");
            form.dayArea.value = phoneParts[0];
            form.dayPrefix.value = phoneParts[1];
            form.daySuffix.value = phoneParts[2];               
            form.submit();
    }

});

And here is the ajax code i want to run instead of the default submission

$.ajax({
    type: "POST",
    url: "/php/localProxy.php",
    data: $('#formEnroll').serialize(),
    success: function (response) {
            document.location = 'http://www.xxxx.com/thank-you';

    },
    error: function () {
            alert('There was a problem!');  // handle error
    }
        });
  • 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-11T06:37:28+00:00Added an answer on June 11, 2026 at 6:37 am

    you can call the the ajax function instead of form.submit();
    form.submit(); will submit your code using default submission.

      $('#formEnroll').on('submit', function(e){
            e.preventDefault(); 
    
            $(this).validate({
                errorElement:"p",
                submitHandler: function(form) {
                    var phoneNumber = form.day_phone.value;             
                    var phoneParts  = phoneNumber.split("-");
                    form.dayArea.value = phoneParts[0];
                    form.dayPrefix.value = phoneParts[1];
                    form.daySuffix.value = phoneParts[2];               
                    submitform();
                }
            });
        })
    
        function submitform(){
        $.ajax({
            type: "POST",
            url: "/php/localProxy.php",
            data: $('#formEnroll').serialize(),
            success: function (response) {
                    document.location = 'http://www.xxxx.com/thank-you';
    
            },
            error: function () {
                    alert('There was a problem!');  // handle error
            }
        });
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a form validation using ajax post method. But i got the
I have a form using jquery validation plugin. My submit button has an ajax
I'm working on a simple JavaScript validation function for a html form, but have
I have a form validation method that's called on submit. It executes a get
I have JavaScript form validation functions like so: function validate_name(field) { if (field ==
I have a multi-lingual page where I want to display form validation error in
I have a small jQuery plugin that I use for form AJAX validation. There
I have a classic asp application. I want to post a contest form from
I have a form with two buttons, a submit button and a cancel/close button.
I have to use a hyperlink instead of a input submit or input button

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.