-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform.html
More file actions
37 lines (33 loc) · 1.05 KB
/
form.html
File metadata and controls
37 lines (33 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form name="form1" action="index.html" method="post" onsubmit="return checkForm()">
<input type="text" name="username" value="" placeholder="username">
<input type="email" name="email" value="" placeholder="email">
<input type="password" name="password" value="" placeholder="password">
<input type="submit" value="Submit">
</form>
<script type="text/javascript">
'use strict';
function checkForm() {
var name = document.forms["form1"]["username"].value;
var email = document.forms["form1"]["email"].value;
var at = email.indexOf('@');
var dot = email.lastIndexOf('.');
if( name===null || name === "" ) {
alert('Name must be filled out!');
return false;
}
else if ( at<1 || dot<at+2 || dot+2>=email.length ) {
alert('Not a valid e-mail address');
return false;
}
return true;
}
</script>
</body>
</html>