-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathsignIn.js
More file actions
39 lines (32 loc) · 1.1 KB
/
signIn.js
File metadata and controls
39 lines (32 loc) · 1.1 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
38
39
document.addEventListener("DOMContentLoaded", function(event) {
const employeeIdEditElement = getEmployeeId();
employeeIdEditElement.focus();
employeeIdEditElement.select();
});
//Get elements for the Employee Id and Password
function getEmployeeId() {
return document.getElementById("employeeId");
}
function getPassword() {
return document.getElementById("password");
}
//Validates the Id is not blank and is a number; Validates that Password is not null
function validateForm() {
const employeeIdEditElement = getEmployeeId();
if(isNaN(Number(employeeIdEditElement.value)) || (Number(employeeIdEditElement.value) <= 0))
{
displayError("Employee Id must be a positive numerical value.");
employeeIdEditElement.focus();
employeeIdEditElement.select();
return false;
}
const passwordEditElement = getPassword();
if ((passwordEditElement.value == null) || (passwordEditElement.value.trim() === ""))
{
displayError("Password must be valid and cannot be blank.");
passwordEditElement.focus();
passwordEditElement.select();
return false;
}
return true;
}