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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:31:03+00:00 2026-05-31T19:31:03+00:00

I know this question will be closed because I studied many example of this

  • 0

I know this question will be closed because I studied many example of this but please see I think I am doing something different.

I coded my server side PHP email validation with this:

if (!filter_var($user_new_email, FILTER_VALIDATE_EMAIL)) {
        $errors .="Email,"; 
        $pass    = false;
             }

My client side email validation is:

function validateEmail(txtEmail){
 var a = document.getElementById(txtEmail).value;
 var filter = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{1,4}$/;
   if(filter.test(a)){
    return true;
   }
   else{
    return false;
   }

So in my client side if I enter only username@domain (without .com), it’s valid. I don’t want that.

I need the same validaton in both client and serverside.
How to update my regular expression in JavaScript?

  • 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-31T19:31:04+00:00Added an answer on May 31, 2026 at 7:31 pm

    Just escape the last ‘.’ (dot) in your regex. When not escaped or inside brackets, a dot matches any character except new line. So the correct value for filter is:

    var filter = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+\.[a-z]{1,4}$/;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, so this question will probably get closed, but hell, its 4:30 in the
I know this will be a difficult question, so I am not necessarily looking
I know this question has been asked before, but I ran into a problem.
I know this question isn't directly programming related, but since I want to be
I know this question has been asked a bit before. But looking around I
I know this question might sound a little cheesy but this is the first
I know this question has been done but I have a slightly different twist
I know this question is overly popular, but I find nothing that addresses rewriting
I know that this is quite subjective, but is it something that I have
I hardly know how to state this question, let alone search for answers. But

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.