Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
How to validate input for only email friendly characters?

I have JavaScript that validates whole email once entered:

function ValidateEmail(inputText)
{
    var mailformat = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/
    if(inputText.value.match(mailformat))
    {
        alert("This is not a valid email address");
        return false;
        }
}

But how to check if single character is valid for email? So I want to prevent users to enter bad email characters. So function param would be these and should return false only if invalid character present:

m
my
mya
....
myaddress
....
myaddress@mail.com
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

great answer: https://stackoverflow.com/a/46181/3764369

issues follows RFC 5322 https://emailregex.com/

w3 code example:

function ValidateEmail(inputText)
{
  var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
  if(inputText.value.match(mailformat))
  {
    alert("Valid email address!");
    document.form.email.focus();
    return true;
  }
  else
  {
    alert("You have entered an invalid email address!");
    document.form.email.focus();
    return false;
  }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!