-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.html
139 lines (129 loc) · 5.32 KB
/
signup.html
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
<!DOCTYPE HTML>
<html>
<head>
<title>Sign Up</title>
<meta charset="utf-8"/>
<meta http-equiv="content-type" content="text/html" />
<meta name ="viewport" content="width=device-width, initial-scale=1" />
<link rel="import" href="bower_components/paper-input/paper-input.html" />
<link rel="import" href="bower_components/paper-button/paper-button.html" />
<link rel="import" href="bower_components/paper-header-panel/paper-header-panel.html" />
<link rel="import" href="bower_components/paper-toolbar/paper-toolbar.html" />
<link rel="import" href="bower_components/paper-dialog/paper-dialog.html" />
<link rel="import" href="bower_components/paper-styles/color.html" />
<link rel="import" href="bower_components/iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="bower_components/iron-ajax/iron-ajax.html">
<link rel="import" href="bower_components/font-roboto/roboto.html">
<script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<style is="custom-style">
body {
font-family: Roboto;
}
.centered {
margin: auto;
margin-left: auto;
margin-right: auto;
margin-top: 50px;
max-width: 420px;
max-height: 450px;
}
img .center{
max-width: 90px;
margin-left: auto;
margin-right: auto;
}
paper-button.blue {
background: #22A7F0;
color: white;
margin-top: 10px;
width: 100%;
}
paper-dialog {
border: 5px;
}
</style>
</head>
<body>
<template is="dom-bind" id="app">
<iron-ajax
id="sendcode"
url="sendverificationcode.php"
handle-as="text"
last-response="{{code}}"></iron-ajax>
<div class="centered">
<paper-material elevation="1" style="padding: 30px; border-radius: 5px">
<center><a href="index.php"><img src="res/anyprintlogo.png" align="middle" alt="Anyprint's Logo" width="90px" height="72px"></img></a></center>
<h3 style="text-align: center; color: #22A7F0;">Create an account for FREE!</h3>
<form id ="formSignUp" action="verify.php" method="post">
<paper-input id= "unamefake" label="Username" pattern="[a-zA-z0-9]*" required auto-validate error-message="Invalid Username" value="{{uname}}" ></paper-input>
<input type="hidden" id="uname" name="uname" />
<paper-input id="upasswordfake" label="Please type your password (8-12 characters)" type="password" minlength="8" maxlength="12" required auto-validate error-message="Invalid password" value={{upassword}}></paper-input>
<input type="hidden" id="upassword" name="upassword" />
<paper-input id="uemailfake" label="Email" type="email" required auto-validate error-message="Invalid email address" value={{uemail}}></paper-input>
<input type="hidden" id="uemail" name="uemail" />
<paper-input id="uhpnumfake" label="H/P Number (0123456789)" minlength="10" maxlength="11" allowed-pattern="[0-9]" required auto-validate error-message="Invalid phone number" value={{uhpnum}}></paper-input>
<input type="hidden" id="uhpnum" name="uhpnum" />
<paper-button name="btnsignup" class="blue" raised onclick="submitHandler()" value="signup">CREATE AN ACCOUNT</paper-button>
<input type="hidden" name="signup" value="signup"/>
</form>
</paper-material elevation="1">
<p>Looking to register your printing shop? Click <a href="businesssignup.html">here</a></p>
</div>
<paper-dialog id="verification" with-backdrop modal>
<h1>Verification Code</h1>
<div>
<p>A 4-digit verification code has been send to <b>{{uhpnum}}</b> to verify your identity. Please key in the code here.</p>
<p><b>NOTE: Your Registration will NOT success unless you key in the correct code</b></p>
<paper-input label="Enter verification code" id="inputCode" value={{inputCode}} maxlength="4"></paper-input>
</div>
<div class="buttons">
<paper-button dialog-dismiss>Cancel</paper-button>
<paper-button autofocus onclick="continueReg()">Continue...</paper-button>
</paper-dialog>
</template>
<script>
var app = document.querySelector('#app');
var canSubmit = true;
var realCode = " ";
var attempt = 5;
var submitHandler = function(){
if(!app.$.unamefake.validate()){
return;
}
if(!app.$.upasswordfake.validate()){
return;
}
if(!app.$.uemailfake.validate()){
return;
}
if(!app.$.uhpnumfake.validate()){
return;
}
var params = {hpnum: app.uhpnum};
app.$.sendcode.params = params;
app.$.sendcode.generateRequest();
var dialog = document.querySelector("#verification");
dialog.open();
}
var continueReg = function(){
if(attempt > 0){
realCode = realCode + app.inputCode
if(app.code == realCode){
//If ok submit the form
app.$.uname.value = app.uname;
app.$.upassword.value = app.upassword;
app.$.uemail.value = app.uemail;
app.$.uhpnum.value = app.uhpnum;
app.$.formSignUp.submit();
}else{
attempt--;
alert("Invalid Code! Left " + attempt + " attempt(s)");
}
}else{
alert("Registration failed! Too many attempts on entering verification code!");
window.location = "signup.html";
}
}
</script>
</body>
</html>