-
Notifications
You must be signed in to change notification settings - Fork 1
/
customer_reg.js
74 lines (51 loc) · 1.81 KB
/
customer_reg.js
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
let regmsg = localStorage.getItem("regmsg")
if(regmsg != null || regmsg != "" || regmsg != undefined)
{
document.getElementById("msg").innerHTML = regmsg;
}
function register()
{
localStorage.removeItem("regmsg");
let name = $('#name').val();
let password = $('#password').val();
let email = $('#email').val();
let phone = $('#phone').val();
if(name == null || name == undefined || name == ""
&& password == null || name == undefined || password==""
&& email == null || email == undefined || email == ""
&& phone == 0 || phone == undefined || phone=="" || phone == null)
{
document.getElementById("msg").innerHTML = "All fields are required please enter all fields";
}
else
{
let customer = [name.trim(),password.trim(),email.trim(),phone.trim()];
let customers = localStorage.getItem("customers");
if(customers == null)
{
customersObj = [];
}
else{
customersObj = JSON.parse(customers);
}
let b=0;
customersObj.forEach(function(e,index)
{
if(e[2] == customer[2])
{
b=1;
}
});
if(b==0)
{
customersObj.push(customer);
location.reload();
localStorage.setItem("regmsg","Registration Successful, You can login Now..");
}
localStorage.setItem("customers",JSON.stringify(customersObj));
if(b==1)
{
document.getElementById("msg").innerHTML = "Registration Failed, Same EmailId already exist";
}
}
}