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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:48:06+00:00 2026-05-27T18:48:06+00:00

Here’s the snapshot of the code: If the function testFields at Line:3 returns false,

  • 0

Here’s the snapshot of the code:

enter image description here

If the function testFields at Line:3 returns false, the control rightly goes to Line:21 and returns false. If testFields returns true, the control goes to Line:4 and then instead of going on to handle the response returned in function at Line:5, the control goes on to Line:21, where the retVal is still false. That is, condition to Line:6 is checked after the function has returned a value to the function:

<form method="POST" onsubmit="return validateInput()" />

Where as, logically, it should first test the condition at Line:7 then decide whether retVal should be true or let it be default false and then value should be returned via Line:21.

What is logically wrong with my code?

  • 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-05-27T18:48:06+00:00Added an answer on May 27, 2026 at 6:48 pm

    There are two ways.

    1. You can make synchronous ajax request.

      var retVal ;
      $.ajax({ 
          url: youUrl,
          async: false, // required to pause script until request is done
          success: function( ret ) { 
             retVal = ret; // ret is invisible outside this callback
      
          },
          error : function( err ) {
            // your error logic
          }
      
      });
      //We'll in this line if request is completed and either success or error callback  was called.  
      return retVal;
      
    2. But if you don’t want the script been stopped. You can prevent a default action in form, and send the form from callback such as:

      $( "form" ).submit( function( e, extra ) { 
      
        if( !extra )
          $.post( 
            url: "script.php",
            data: "yourdata",
            success: function( ) {  
              $( "form" ).trigger( "submit", [true] );         
            },
           error: function(){}
       );
      
         // extra parameter will be always undefined until we'll not pass it in an array which will be aplied to listener as  next ones arguments - take a look at success callback
        return !!extra  // doubled negate operator ensures that extra will be returned as boolean because if you return undefined  that means you didn't return anything 
      });
      

    and in html form tag without onsubmit declaration :

    <form method="POST" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is an example: I write html code inside of textarea, then I swap
Here my code: $(document).ready(function() { $('#mid_select').live('click', function(e){ $('#middle').load( $(this).attr('href') + ' #middle'); var page
here is javascript code: var test = { h : function (a) {return a;},
Here is a function from Dreamweaver, if (($strUsers == ) && false) what the
Here is my code, which takes two version identifiers in the form 1, 5,
Here is my code...I have two dimensional matrices A,B. I want to develop the
Here is my code sample, let me know if it can be further improved?
Here is my code (Say we have a single button on the page that
here are 2 screen shots when i try to debug my code in visual
Here a simple question : What do you think of code which use try

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.