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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:38:43+00:00 2026-06-04T04:38:43+00:00

I have two pieces of javascript that I would like to work together. I

  • 0

I have two pieces of javascript that I would like to work together. I have a form that is submitted via ajax, and a form validation script, that I would like to work together to prevent the ajax form submission if the validation fails.

Here is the ajax form submission script:

<script type="text/javascript">
$(document).ready(function(){$(".sendName").click(function(){
var jsuser=$("#jsuser").val();
var jemail=$("#jemail").val();
var jusid=$("#jusid").val();
$.post("recomend.php",{jsuser:jsuser,jusid:jusid,jemail:jemail},function(data){$("#loadName")
.html(data)
.effect('bounce', { times: 5, distance: 30 }, 300);
  });
 });
});
$('#start').click(function() {
  $('#effect').toggle('fast', function() {
   });
});
</script>

This code works perfectly, and the form is submitted.

I also have the validation code partially working. If incorrect information is entered the error message is shown beside the field, but the form can still be submitted.

On a normal form the validation code is called like this:

<form method="post" action="formprocess.php" name="form1" id="form1" onsubmit="return validate(this)">

So, I need to know how to do the equivalent of:

onsubmit="return validate(this)"

in the ajax submission code, and not submit the form if there are errors.

  • 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-04T04:38:44+00:00Added an answer on June 4, 2026 at 4:38 am

    Why don’t you just do the following?

    <script type="text/javascript">
    
    $(document).ready(function(){$(".sendName").click(function(){
    
    var jsuser=$("#jsuser").val();
    var jemail=$("#jemail").val();
    var jusid=$("#jusid").val();
    if(validate(jsuser, jemail, jusid)){
    $.post("recomend.php",{jsuser:jsuser,jusid:jusid,jemail:jemail},function(data){$("#loadName")
    .html(data)
    .effect('bounce', { times: 5, distance: 30 }, 300);
      });
     });
    });
    $('#start').click(function() {
      $('#effect').toggle('fast', function() {
       });
    });
    }
    </script>
    

    Where validate does your validation

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

Sidebar

Related Questions

I have a simple PHP script with a form that has two select fields,
I have two pieces of jquery code, they work perfectly separate, but together -
I have two pieces of code.They work properly when it is used alone in
I have two very similar pieces of ASP.NET code that send a file in
I have a list of tuples pairing two pieces of data... I'd like to
I have two pieces of code that I'm using to learn about multiprocessing in
I have two pieces of code which are very similar in that they register
I'm parsing a binary file in javascript that is storing two pieces of information
I have two pieces of C++ code running on 2 different cores. Both of
I have two essentially separate applications for configuring two pieces of hardware sold by

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.