Skip to content

Commit fca4dcb

Browse files
committed
basic html client login form validation
relates #2
1 parent 6fb8462 commit fca4dcb

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Public/login.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
<body>
88
<section>
99

10-
<form class="login__form" action="/login" method="POST" novalidate>
10+
<form class="login__form">
1111

1212
<label for="username">Username:
13-
<input id="username" type="text" required/>
13+
<input id="username" type="text" required pattern="^[a-zA-Z0-9]+$" title="Please provide an alphanumeric name"/>
1414
</label>
1515
<label for="password">Password:
16-
<input id="password" type="password" required pattern="^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$" />
16+
<input id="password" type="password" required pattern="^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$" title="Password should contain more than 8 characters, at least 1 capital letter and 1 number"/>
1717
</label>
1818

1919
<p class="error" aria-live="polite"></p>
2020

21-
<button>login</button>
21+
<input type="submit" id="loginButton" value="login"/>
2222
</form>
2323

2424
</section>

Public/login.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
const username = document.getElementById('username');
22
const password = document.getElementById('password');
3+
4+
const loginButton = document.getElementById('loginButton');

Src/server.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const http = require('http');
2+
const router = require('./router.js');
3+
4+
const server = http.createServer(router);
5+
const port = process.env.PORT || 7000;
6+
const host = process.env.HOST || 'localhost';
7+
8+
server.listen(port, () => {
9+
console.log(`Magic happens at http://${host}:${port}`);
10+
});

0 commit comments

Comments
 (0)