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

  • Home
  • SEARCH
  • 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 4585772
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:32:36+00:00 2026-05-21T21:32:36+00:00

I wonder how I can confirm the email is having a @ sign using

  • 0

I wonder how I can confirm the email is having a @ sign using javascript before submitting to signUp.php?

<form action='signUp.php'>
    <input type='text' name='email'>
    <input type='text' name='firstName'>
    <button value='submit'>
</form> 
  • 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-21T21:32:37+00:00Added an answer on May 21, 2026 at 9:32 pm

    You need to use this javascript:

    /@/.test(document.forms[0].email.value)
    

    in your form:

    <button value='submit' onclick='javascript: if (/@/.test(document.forms[0].email.value) == true) { document.forms[0].submit(); } else { return; }' />
    

    I’d better prefer to use something like following:

    HTML:

    <form action='signUp.php' id='theform'>
        <input type='text' name='email' id='email'>
        <input type='text' name='firstName'>
        <button value='submit' onclick='javascript: checkform(); return;'>
    </form>
    

    Javascript:

    var checkform = function() {
      var theform = document.getElementById('theform');
      if (is_email(document.getElementById('email').value))) {
        theform.submit();
      }
      return;
    }
    var is_email = function(val) {
      return /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum|travel)$/.test(val)
    }
    

    ^[a-zA-Z0-9._%+-]+@[A-Z0-9.-]+\.(?:[a-zA-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum|travel)$ is a regular expression that checks is a value is a valid email address string. In your question you’ve asked just to test an existence of @ in your string, but, hey! not@email will be matched! You certainly don’t want to allow strings like that to be treated as valid email strings.

    Basicly, you want to check your form data before form submit action. So you can do either:

    • <form onsubmit='if (!checkform()) reutrn;'>
      or
    • <input type='submit' onclick='checkform()' />

    In checkform function you validate fields data and if validation is passed, you call submit method on html form object and you return false or nothing (e.g. return;) otherwise.

    You should also learn how to use regular expressions within javascript here

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

Sidebar

Related Questions

I wonder how can I get the list of MySQL databases in PHP using
I wonder if someone can help: Long story short, I'm using MSSQL2005 to build
i wonder how can i schedule and automate tasks in PHP? can i? or
Again i wonder how can i highlight selected item in my MainMenu form. Every
I wonder how can I insert some JSP fragment into the BodyContent before it
I am a beginner in web/javascript programming and wonder if anyone can give me
I want to use a confirm box for user to check before submitting the
I wonder how can i find out last in table with PHP, aka if
I wonder how can I export a Visual Studio C++ project to Qt? I
I wonder how can I search for a certain pattern in file, but only

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.