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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:30:23+00:00 2026-06-11T21:30:23+00:00

I have the following html <form action= class=form-horizontal id=submitForm> <input class=required input-xxlarge type=text placeholder=Please

  • 0

I have the following html

<form  action="" class="form-horizontal" id="submitForm">
  <input class="required input-xxlarge" type="text" placeholder="Please enter a suitable title" name="title">
  <br><br>
  <div id='container' class="well">
    <br>
    <textarea class="span8 required" id='mytextarea' wrap='on'>
      Please enter some value
    </textarea>
    <br>
    <input class="btn btn-info" type="submit" id="submit-button" value="Submit">
  </div>

</form>

When the user clicks submit, I want to send the textarea data as well as the text data to a url. I am also using the validation plugin, just to ensure client side verification.

And the following is my jQuery:

 $(function() {
    $("#submitForm").submit(function(){
        if ($("#submitForm").validate()){
            $.post("/create/post/",
                   {'data':$('#mytextarea').val()},
                   function(data){
                       console.log(data);
                       alert(data);
                   });
        }
    });
    });

As of now it does not seem to work, what is wrong? How can I override the submit button, perform validation and then post the data to the server?

  • 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-11T21:30:24+00:00Added an answer on June 11, 2026 at 9:30 pm

    validate() is just the initialization method for the plugin, not the one supposed to be used to check if the form is valid. Your provided code always “validates” to true, because validate() returns the validation object. The actual check to see whether the form is valid is what valid() is for.

    In addition, as Demao wrote, you need to stop the event propagation so the form is submitted with ajax. One way is by returning false at the end of the callback.

    So your code should be something like:

    $(function() {
        $("#submitForm").validate();
    
        $("#submitForm").submit(function(){                       
            if ($("#submitForm").valid()){
                $.post("/create/post/",
                       {'data':$('#mytextarea').val()},
                       function(data){
                           console.log(data);
                           alert(data);
                       });
            }
            return false;
        });
     });​
    

    Here is a demo: http://jsfiddle.net/hzcF7/

    Another way to do this would be to let the plugin do the validation itself and just tell it what to do if the form is valid, using the submitHandler option when you initialize the validation object. Like this:

    $(function() {
        $("#submitForm").validate({
            submitHandler: function() {
                $.post("/create/post/",
                   {'data':$('#mytextarea').val()},
                   function(data){
                       console.log(data);
                       alert(data);
                   });
            }
        });
     });​​​
    

    Demo

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

Sidebar

Related Questions

I have the following html code: <form> <table> <tbody> <tr> <td> <span>Quantity<span class=pull-right>3</span> <input
Suppose I have the following HTML: <form id=myform> <input type='checkbox' name='foo[]'/> Check 1<br/> <input
I have a form with the following HTML below: <form id=course_edit_form name=course_form action=/courses/save method=post>
I have a html file like following: <form action=/2811457/follow?gsid=3_5bce9b871484d3af90c89f37 method=post> <div> <a href=/2811457/follow?page=2&amp;gsid=3_5bce9b871484d3af90c89f37>next_page</a> &nbsp;<input
I have a simple html form that looks like the following <form action=search.php method=get>
I have the following PHP code: echo ' <td id='.$metaso['semanaventa'].'td1><form id='.$metaso['semanaventa'].'form name='.$metaso['semanaventa'].'form class=dinamic action=compromiso_funciones.php
I have the following form in cakephp: <div class=quickcontactDisplay> <?php echo $form->create('Enquiry',array('action'=>'add','class'=>'quickcontact')); echo $form->hidden('visitor_id',
I have the following HTML: <div id=modal ><div class=modal-window> <ul class=action-tabs right> <li><a href=#
I have the following starting HTML: <div id=modal ><div class=modal-window> <ul class=action-tabs right> <li><a
Hi, I have the following in my view : <form id=list_ad method=get class=adListFilter action=<%=Url.Action(List,

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.