-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoffice tester
144 lines (119 loc) · 4.21 KB
/
office tester
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<style>
.main{
width:1000px;
height:auto;
border:solid 2px red;
margin:0 auto;
}
input{
margin:20px;
}
#submit{
text-align:right;
}
</style>
<script>
var attempt = 3; // Variable to count number of attempts.
// Below function Executes on click of login button.
function main(){
}
function getAge(dateString) {
dateString= dateString.replace("-","/");
var today = new Date();
var birthDate = new Date(dateString);
var age = today.getFullYear() - birthDate.getFullYear();
var m = today.getMonth() - birthDate.getMonth();
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
console.log(age);
return age;
}
function validateAddress(){
var TCode = document.getElementById('address').value;
if( /[^a-zA-Z0-9\-\/]/.test( TCode ) ) {
alert('Input is not alphanumeric');
return false;
}
return true;
}
function validate(){
var mydate= document.getElementById("DOB").value;
//console.log(mydate);
//getAge(mydate);
//document.getElementById("age").value=getAge(mydate);
fNameValidator();
lNameValidator();
//getBirthday();
}
function fNameValidator(){
var username = document.getElementById("username").value;
console.log(username);
if(!specialCharacterValidator(username,"text") && username=="" ){
console.log("please enter number value");
return false ;
}
}
function lNameValidator(){
var password = document.getElementById("password").value;
console.log(specialCharacterValidator(password,"email"));
if(!specialCharacterValidator(password,"email") && password=="" ){
console.log("please enter email value");
}
}
function getBirthday(){
document.getElementById("age").value=getAge(mydate);
}
function specialCharacterValidator(username, value) {
//Regex for Valid Characters i.e. Alphabets, Numbers and Space.
var regex;
if(value == "number"){
regex = /^[0-9 ]+$/
}
if(value == "text"){
regex = /^[a-zA-Z0-9 ]+$/
}
if(value == "email"){
regex =/^\S+@\S+$/
}
//Validate TextBox value against the Regex.
var isValid = regex.test(username);
if (!isValid) {
alert("Contains Special Characters.");
} else {
alert("Does not contain Special Characters.");
}
return isValid;}
</script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> -->
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> -->
<link type='text/css' rel='stylesheet' href='CSS/style.css' />
<!-- <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
-->
</head>
<body>
<div class="container" onload="main()" >
<div class="main">
<form id="form_id" method="post" name="myform">
<label>User Name :</label>
<input type="text" name="username" id="username"/><br/>
<label>Password :</label>
<input type="text" name="password" id="password"/><br/>
<label>DOB :</label>
<input type="date" name="birth date" id="DOB" placeholder="yyyy/mm/dd" maxlength="10" pattern="\d{1,2}\/\d{1,2}\/\d{4}" required="required"/><br/>
<label>age :</label>
<input type="number" name="birth date" id="age" maxlength="10" required="required" disabled/><br/>
<input type="button" value="Next" id="submit" onclick="validate()" />
</form>
</div>
</div>
</body>
</html>