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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:24:16+00:00 2026-05-18T01:24:16+00:00

I have a designer insisting on a single form field submitted by hitting enter

  • 0

I have a designer insisting on a single form field submitted by hitting enter and the post made by AJAX and the response presented by Fancybox.

Problem is the the return false is not preventing the submission of the page.

What am I doing wrong there?

<form id="home_stay_informed_form">
<input name="informed_email" id="home_informed_email" value="Enter your email address..." />
</form>


$('#home_stay_informed_form').submit(function() {
  var reg = new RegExp(/^\S+@\S+\.\S+$/);
  var em = $("#home_informed_email").val();
  if (!reg.test(em)) {
  alert('Please correct your email address.');
  $("#home_informed_email").focus();
    return false;
  } else {
  $.ajax({
    type: "POST",
    url: 'listSubscribe.php',
    data : 'email=' + em,
    success: function(msg) {
     $("#home_stay_informed_form_msg").fancybox({
    'titlePosition'  : 'outside',
    'transitionIn'  : 'none',
    'transitionOut'  : 'none'
   });
    $("#home_informed_email").val('Enter your email address...');
    return false;
    }
  });   
  }
});
  • 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-18T01:24:17+00:00Added an answer on May 18, 2026 at 1:24 am

    The return false needs to do in the submit handler directly, like this:

    $('#home_stay_informed_form').submit(function() {
      var reg = new RegExp(/^\S+@\S+\.\S+$/);
      var em = $("#home_informed_email").val();
      if (!reg.test(em)) {
        alert('Please correct your email address.');
        $("#home_informed_email").focus();
      } else {
        $.ajax({
          type: "POST",
          url: 'listSubscribe.php',
          data : 'email=' + em,
          success: function(msg) {
            $("#home_stay_informed_form_msg").fancybox({
              'titlePosition'  : 'outside',
              'transitionIn'  : 'none',
              'transitionOut'  : 'none'
            });
            $("#home_informed_email").val('Enter your email address...');
          }
        });   
      }
      return false;
    });
    

    Your success handler doesn’t run until the server response comes back, so your function is actually returning undefined for that else statement…and that return false inside doesn’t have any effect. Putting it in the submit handler directly like is it above will do what you want, preventing the form submit.


    A bit cleaner would be event.preventDefault(), by adding the event parameter here:

    $('#home_stay_informed_form').submit(function(e) {
    

    And replacing return false with

    e.preventDefault();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Windows Forms allows you to develop Components, non-visual elements that can have a designer.
I have been programming using PHP, Javascript and have been a designer for a
I have a problem in my project with the .designer which as everyone know
Does anyone have any experience hosting the Windows Workflow designer surface? I've seen a
I have a number of custom controls that I am trying to enable designer
I am not a designer, but I have noticed many changes between firefox and
Does anybody use the Class Designer much in Visual Studio? I have downloaded the
I have designed database tables (normalised, on an MS SQL server) and created a
I have Designed the Javascript function My.js it contains following code My.js function display(){
I have a poorly designed database. One of the most important tables has 11,000+

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.