-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathheadline_studio.js
65 lines (52 loc) · 1.36 KB
/
headline_studio.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
let userArr=JSON.parse(localStorage.getItem("users"))|| [];;
class User{
constructor(name,id,e,p){
this.name=name;
this.id=id;
this.email=e;
this.password=p;
}
signUp(email,password){
let isValidated=false;
isValidated=this.#isValidatEmail(email) && this.#isValidatePassword(password);
console.log(this)
if(isValidated){
this.email=email;
this.password=password;
userArr.push(this);
console.log(userArr,this)
localStorage.setItem("users",JSON.stringify(userArr));
window.location.href="login.html"
alert("Registration Successful!");
}
else{
alert("Your password must include at least 8 characters.");
}
}
#isValidatEmail(email){
if(email.length<8){
return false;
}else{
return true;
}
}
#isValidatePassword(password){
if(password.length<8){
return false;
}else{
return true;
}
}
}
let id=0;
let signUp=()=>{
id++;
let name=document.querySelector("#name").value;
let email=document.querySelector("#email").value;
let password=document.querySelector("#password").value;
user1=new User(name,id,email,password);
user1.signUp(email,password);
console.log(userArr)
// localStorage.setItem("users",JSON.stringify(userArr));
// window.location.href="login.html"
}