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

143
Views
Email validation coding in node.is

This is the email validation coding.

I only know to do example 5, the email length must over 5 strings, otherwise, it will become error and remind people to re-write the email.

I don’t know how to write the example 2-4 based on the email requirements. Kindly please give me some advices. Thank you so much!

function validateEmail(email) {
    console.log(email)
  // email requirements as below:
  // email length >= 5 character
  // @ cannot be the first character
  // @ must before .
  // . cannot be the last character
  // example 
  // 1. a@a.com < return true
  // 2. @a.com < return false, throw TypeError: invalid email address
  // 3. a.b@com < return false, throw TypeError: invalid email address
  // 4. a@a.com. < return false, throw TypeError: invalid email address
  // 5. a@a.c < return false, throw TypeError: e-mail address too short
  // 6. a@.com < return ture
  // example 5, email length >= 5 character
  if(email.length<5) {
    throw new TypeError(`e-mail address too short`)
  }
  // example 4,  . cannot be the last character
  
  }
// example 1,6
    return true

    function newFunction() {
        return "'"
    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can follow this REGAX for validate email. Please check

const emailToValidate = 'a@a.com';
const emailRegexp = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
console.log(emailRegexp.test(emailToValidate));

Thanks

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!