html
html
1
2
3
4
5
6
7
8
9
10
11
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<label for="email">Emali</label>
<input type="email" id="email">
<button id="submit" type="submit">Submit</button>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
body {
display:grid;
place-items:center;
justify-content:center ;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
window.onload=()=>{
let subimt = document.querySelector("#submit");
let validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
subimt.addEventListener("click",()=>{
let email = document.querySelector("#email").value;
if(email.match(validRegex)){
console.log("true")
}
else if(!email.match(validRegex)){
console.log("false")
}
})
}
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run