Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 99913d8

Browse files
email validation first stage
1 parent 7691776 commit 99913d8

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

‎day19/STARTER-FILES/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ <h1>Signup</h1>
5151
<input type="submit" name="submit" value="Submit" />
5252
</div>
5353
</form>
54-
<script src="/day19/app.js"></script>
54+
<script src="/.//app.js"></script>
5555
</body>
5656
</html>

‎day19/app.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const inputsNodeList = document.querySelectorAll("input");
2+
3+
const inputName = document.querySelector("input#name");
4+
const inputEmail = document.querySelector("input#email");
5+
const inputPassword = document.querySelector("input#password");
6+
const inputConfPassword = document.querySelector("input#confirm-password");
7+
8+
// console.log(inputsNodeList);
9+
10+
const validateUserName = (e) => {
11+
e.preventDefault();
12+
const usernameRegex = /^[a-zA-Z0-9-\s]+$/;
13+
14+
if (!usernameRegex.test(e.key)) return false;
15+
e.target.value += e.key;
16+
};
17+
18+
inputName.onkeypress = validateUserName;
19+
20+
const validateEmail = (e) => {
21+
// e.preventDefault();
22+
const emailRegex = /^[a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,6}$/i;
23+
24+
console.log(emailRegex.test(inputEmail.value));
25+
26+
// if (!emailRegex.test(e.key)) return false;
27+
// e.target.value += e.key;
28+
};
29+
30+
inputEmail.oninput = validateEmail;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /