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

  • Home
  • SEARCH
  • 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 8388061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:23:08+00:00 2026-06-09T18:23:08+00:00

I need to validate a form using jQuery then submit it to a JavaScript

  • 0

I need to validate a form using jQuery then submit it to a JavaScript file that redirects it to the confirmation/send mail page. The reason I am doing this is to prevent spam emails with out putting some type of Captcha in. I am basically putting in a wrong url for the post to page of the form and then changing that to the correct page in an external JavaScript file. Everything works great except the form submits before it validates. I can see it mark the errors for a slight second before it submits.

Validation JS:

<script type="text/javascript">
$(document).ready(function(){

    $('#contactform').submit(function() {
      return $('#contactform').valid();
    });

        $("#contactform").validate();

            $("#Name").rules("add", {
        required: true,
        minlength: 5,
        messages: {
        required: "Required",
        minlength: jQuery.format("Minimum {0} Characters Required")
     }   
    }); 
        $("#Question").rules("add", {
        required: true,
        minlength: 20,
        messages: {
        required: "Required",
        minlength: jQuery.format("Question Must Be {0} Character Long")
     }

    });

    $("#math").rules("add", {
        required: true,
        equalTo: "#math2",
        messages: {
        required: "Solve Security Question.",
     }
    });


});
</script>

External JS Redirect:

function submitCommentForm() {
    // Change the form action to the real submission page
    document.getElementById('contactform').action = "confirmation.php";
    // Submit the form
    document.getElementById('contactform').submit();
}
  • 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-09T18:23:10+00:00Added an answer on June 9, 2026 at 6:23 pm

    Change

    $('#contactform').submit(function() {
      return $('#contactform').valid();
    });
    

    To

    $('#contactform').submit(function() {
      if($(this).valid()){
        submitCommentForm();
      }else{
        alert('Please fix the errors within the form.');
      }
      return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to validate input using JavaScript and jQuery when someone submit my newsletter
I have a script that validates a form (using jQuery Validate ) and then
I need to be able to validate fractions on my form using jquery.validate and
Im using jQuery.validity plugin to validate PHP form. I need to validate whether the
I'm using jQuery.validity to validate PHP form inputs. I need to skip validation when
I'm using jQuery Validate for a form. I need to add some functionality so
I'm trying to validate a php register form using valid8 jquery plugin. i need
I am using jquery validate form script and need to add it a captcha
I m using jquery validator plugin. i need to validate some field with some
I'd like to validate a form using the jquery validate plugin, but I'm unable

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.