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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:33:39+00:00 2026-05-26T12:33:39+00:00

In the script below I check if the email entered is valid. It is

  • 0

In the script below I check if the email entered is valid. It is not the best regex but it is ok for now. Also for the moment I do not make any server side check for input. Only with this script.

I have this problem though:
When an email is valid, and after I type an invalid email I get first the Your email is not in valid format and then You will be notified when we launch. Thank you! alert. Also the email is sent. How to fix this ?

Thank you

this is my form

<form id="myform" action="" method="POST">
                <input id="subscribe" name="subscribe" class="subscribe floatLeft" type="text">
                <button id="signUp" class="signUp floatRight" ><intro>notify!</intro></button>              
                <div class="clear">&nbsp;</div>
</form>

and here is the script

var signUp = function(inputEmail) {
    var isValid = true;
    var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
    if (!emailReg.test(inputEmail)) {
        isValid = false;
        alert('Your email is not in valid format');
    }



$("#myform").submit(function(event) {
    event.preventDefault();
    if (!isValid) {
        return false;
    } else {
        $.post('mailme.php', $("#myform").serialize(), function(data) {
            alert('You will be notified when we launch. Thank you!');

        });
        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-26T12:33:39+00:00Added an answer on May 26, 2026 at 12:33 pm

    You need the onsubmit event to return false;
    You need to bind the submit event anyway and make the isValid check there;

    $("#myform").submit(function(event){
      event.preventDefault();
      if(!isValid){
      return false;
     }else{
      $.post(...)
      return false;
     }
    });
    

    –Edit–
    Forgot to return false/event.preventDefault; But like i said, the submit event need to be bound anyway

    –Edit2–

    function validEmail(email){
    var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
    return email.test(emailReg)
    }
    $(document).ready(function(){
      $("#myform").bind({
        submit: function(e){
         e.preventDefault();
         if(validEmail($("#myform").find("#subscribe").val()){
           $.post(...)
              alert("You will be notified");
             return false;
         }
         else {
            alert("Invalid email");
            return false;
         }
    
       });
    

    });
    }

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

Sidebar

Related Questions

Script below is not working. Not getting any php error messages. Had asked a
The script below will replace selected word in a textarea. But it only works
The script below worked on my Mac OS X. I'm now using Ubuntu OS,
The script below should open all the files inside the folder 'pruebaba' recursively but
I have tested the below script on a demo page which is not using
I've tried the below script but I am getting an error: dim cn, rs
The below check is not working: if [ $LEN = `expr $CNPROC + $CTotal`
I would like to check the existence of directory and write the script below,
Hi I have created the code below to check if a user is valid
I have a script to check if any data is available on svn repo

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.