cleanup
This commit is contained in:
parent
6c17b4d5af
commit
c337cd413b
@ -1,31 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>JavaScript Course</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="output"></div>
|
|
||||||
<input type="text" placeholder="Enter Email">
|
|
||||||
<button>Check</button>
|
|
||||||
<script>
|
|
||||||
const output = document.querySelector(".output");
|
|
||||||
const emailVal = document.querySelector("input");
|
|
||||||
const btn = document.querySelector("button");
|
|
||||||
const emailExp = /([A-Za-z0-9._-]+@[A-Za-z0-9._-]+\.[A-Za-z0-9]+)\w+/;
|
|
||||||
btn.addEventListener("click", (e) => {
|
|
||||||
const val = emailVal.value;
|
|
||||||
const result = emailExp.test(val);
|
|
||||||
let response = "";
|
|
||||||
if (!result) {
|
|
||||||
response = "Invalid Email";
|
|
||||||
output.style.color = "red";
|
|
||||||
} else {
|
|
||||||
response = "Valid Email";
|
|
||||||
output.style.color = "green";
|
|
||||||
}
|
|
||||||
emailVal.value = "";
|
|
||||||
output.textContent = response;
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Loading…
x
Reference in New Issue
Block a user