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

The Archive Base Latest Questions

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

I am trying to submit a form after validating captcha using an ajax request

  • 0

I am trying to submit a form after validating captcha using an ajax request – if captcha is validated successfully , i have to submit the form.

here is the form :

<form action="Feedback" method="post" name="contact_us" id="contact_us_form">
     <table id="contact_us_table" style="font-family: 'Muli', serif;font-weight:bold;margin-left: 26px;margin-top: 39px;">

     <tr>
     <td> </td>
     <td height="20px" style="color: red;font-size: 12px;" id="msg">  </td>
     </tr>
     <tr>
     <td><span style="color: red">*</span>Name  </td>
     <td> <input type="text" name="name" id="name" /> </td>
     </tr>

     <tr>
     <td><span style="color: red">*</span>Email  </td>
     <td> <input type="text" name="email" id="email" /> </td>
     </tr>


     <tr>
     <td width="100px;"><span style="color: red">*</span>Message  </td>
     <td> <textarea style="max-width:420px;width: 420px; height: 100;" name="message" id="message"></textarea></td>
     </tr>

     <tr>
     <td height="50px;"></td>
     <td>Human Verification.</td>
     </tr>




     <tr>
     <td><img src="<%=GlobalData.SERVER_ROOT+"simpleCaptcha.png"%>"></td>
     <td height="20px;"><input type='text' name='answer' id="answer" value=''> </td>
     </tr>

     <tr>
     <td></td>
     <td> <button class="button1" id="submit">Submit</button> </td>
     </tr>


     </table>
     </form>

and here is the javascript :

 $("#contact_us_form").submit(function(e){
             e.preventDefault();
            var email = $("#email").val(); 
            var name = $("#name").val(); 
            var message = $("#message").val();
            var answer = $("#answer").val();



            if(name == ""){
                   $("#name").focus();
                   $("#msg").html("Please enter your name");
                   return false;
                  }
            else if(email == ""){
               $("#email").focus();
               $("#msg").html("Please enter an email");
               return false;
              }
             else if(!isValidEmailAddress(email)){
               $("#email").focus();
               $("#msg").html("Email should be like : john@example.com");
               return false;
              }
             else if(message == ""){
                 $("#message").focus();
                   $("#msg").html("Please write your message");
                   return false;
                 }
             else if(answer == ""){
                 $("#answer").focus();
                   $("#msg").html("Enter what you see in image.");
                   return false;
                 }



             $.ajax({
                 type: "POST",
                 url: "CheckCaptcha",
                 data: {answer:answer}
             }).done(function(msg) {
                // alert(msg);

                 if(msg == "true"){
                    //$('#contact_us_form').submit();
                    //$('#contact_us_form').submit(); 
                       $("#contact_us_form").unbind('submit').submit();
                     //setTimeout(document.getElementById('contact_us_form').submit(), 10);
                 }
                 else{
                     $("#answer").focus();
                       $("#msg").html("Captcha Incorrect");
                       return false;
                     }
                 }).error(function(){

                 });



            });

You can see in javascript :

if(msg == "true"){

                    //$('#contact_us_form').submit(); 
                       $("#contact_us_form").unbind('submit').submit();
                     //setTimeout(document.getElementById('contact_us_form').submit(), 10);
                 }

i have tried all i can . but it didn’t work.

is their anything wrong ?

EDIT ::

This code works if i click submit two times..

  • 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:48:09+00:00Added an answer on June 9, 2026 at 6:48 pm

    It’s just because of this :

    <button class="button1" id="submit">Submit</button>
    

    NEVER USE ‘type’ as a name or id

    i was using submit as an id. that is why the code was not working..

    when i changed it to

    <button class="button1" id="submit_button">Submit</button>
    

    it worked !

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

Sidebar

Related Questions

I am trying to submit a form using Ajax.Updater and have the result of
I am trying to submit a form using jsRoutes in ajax after first doing
I am trying to have my form fields submit after the onchange event. The
I am trying to submit a form with ajax. Here is my complete code
I'm trying to submit a form via AJAX and prevent a redirect after the
I am trying to submit a form by using jquery automatically after page load
I have a html form and validated it using jquery bassitance plugin, then after
Im trying to submit a form with Ajax here's my simplified code My index:
I'm trying to submit a form when a select changes using jQuery Mobile. I
I am trying to submit a form with method GET and action index.php?id=3. The

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.