Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Intro component with signup

JohPr 90

@JohPr

Desktop design screenshot for the Intro component with sign-up form coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


Hello Everyone, Unfortunately I didn't manage to validate the email. Do you guys have any solutions? Any feedback would be greatly appreciated!

Community feedback

Carl 815

@CarlHumm

Posted

Hi there

Before regular expressions can be used, they have to be compiled.

The literal notation results in compilation of the regular expression when the expression is evaluated. Sources: MDN

To evaluate an expression you can use one of the prototype methods available to you - the most common being .prototype.test() which returns a true/false Boolean.

Using the strict equality operator like in the example below will not compile and evaluate the regex.

    if (email.value === pattern) {
        email.style.border = "2px solid green";
    }

The following however will compile and evaluate the regex against the specified email input. Within the conditional we are saying if this test fails, then it's not valid.

 if(!pattern.test(email.value)) {  
    console.log('That email is not valid!');
} 

Hope this helps :)

Marked as helpful

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord