@@ -31,16 +31,186 @@ export class SignupFormComponent{
31
31
state :string ;
32
32
country :string ;
33
33
zip :string ;
34
+
35
+ d :any = new Date ( ) ;
36
+ formattedDate :any = this . d . toISOString ( ) ;
37
+ action :string ;
38
+ details :string ;
39
+ validate = true ;
40
+ errors :any ;
34
41
35
- constructor ( private _httpWebService : HttpWebApiService , private router : Router ) { }
42
+ constructor ( private _httpWebService : HttpWebApiService , private router : Router ) {
43
+ this . action = "" ;
44
+ }
45
+
46
+
47
+
48
+ resolved ( captchaResponse : string ) {
49
+ if ( captchaResponse != null ) {
50
+ document . getElementById ( "signup" ) . classList . remove ( "hidebutt" ) ;
51
+ } else {
52
+ document . getElementById ( "signup" ) . classList . add ( "hidebutt" ) ;
53
+ }
54
+ }
36
55
37
56
38
57
39
58
40
59
validateSignUp ( ) {
41
60
42
- this . router . navigate ( [ 'signupsuccess' ] ) ;
61
+ document . getElementById ( "username" ) . classList . remove ( "invalid-input" ) ;
62
+ document . getElementById ( "password" ) . classList . remove ( "invalid-input" ) ;
63
+ document . getElementById ( "cpassword" ) . classList . remove ( "invalid-input" ) ;
64
+ document . getElementById ( "userid" ) . classList . remove ( "invalid-input" ) ;
65
+ document . getElementById ( "usertype" ) . classList . remove ( "invalid-input" ) ;
66
+ document . getElementById ( "company" ) . classList . remove ( "invalid-input" ) ;
67
+
68
+ document . getElementById ( "department" ) . classList . remove ( "invalid-input" ) ;
69
+ document . getElementById ( "firstname" ) . classList . remove ( "invalid-input" ) ;
70
+ document . getElementById ( "lastname" ) . classList . remove ( "invalid-input" ) ;
71
+ document . getElementById ( "dob" ) . classList . remove ( "invalid-input" ) ;
72
+ document . getElementById ( "phone" ) . classList . remove ( "invalid-input" ) ;
73
+ document . getElementById ( "address" ) . classList . remove ( "invalid-input" ) ;
74
+ document . getElementById ( "city" ) . classList . remove ( "invalid-input" ) ;
75
+ document . getElementById ( "state" ) . classList . remove ( "invalid-input" ) ;
76
+ document . getElementById ( "country" ) . classList . remove ( "invalid-input" ) ;
77
+ document . getElementById ( "zip" ) . classList . remove ( "invalid-input" ) ;
78
+
79
+
80
+
81
+ if ( this . username == null || this . username == "" ) {
82
+ document . getElementById ( "username" ) . classList . add ( "invalid-input" ) ;
83
+
84
+ this . action = "Oh snap! Provide an Email id and try submitting again." ;
85
+ this . validate = false ;
86
+ }
87
+ else {
88
+ if ( EMAIL_REGEX . test ( this . username ) )
89
+ this . validate = true ;
90
+
91
+ else {
92
+ document . getElementById ( "username" ) . classList . add ( "invalid-input" ) ;
93
+
94
+ this . action = "Oh snap! Change your email id and try submitting again." ;
95
+ this . validate = false ;
96
+ }
97
+ }
98
+
99
+ console . log ( this . username ) ;
100
+
101
+ if ( this . password == null || this . password == "" ) {
102
+ document . getElementById ( "password" ) . classList . add ( "invalid-input" ) ;
103
+ this . action = "Enter a Valid password." ;
104
+ this . validate = false ;
105
+ } else {
106
+ if ( this . confirm == null || this . confirm == "" ) {
107
+ document . getElementById ( "cpassword" ) . classList . add ( "invalid-input" ) ;
108
+ this . action = "Enter a Valid password." ;
109
+ this . validate = false ;
110
+ } else {
111
+ if ( this . password != this . confirm ) {
112
+ document . getElementById ( "password" ) . classList . add ( "invalid-input" ) ;
113
+ document . getElementById ( "cpassword" ) . classList . add ( "invalid-input" ) ;
114
+ this . action = "The passwords do not match." ;
115
+ this . validate = false ;
116
+ }
117
+ }
118
+ }
119
+
120
+
121
+ if ( this . department == null || this . department == "" ) {
122
+ document . getElementById ( "department" ) . classList . add ( "invalid-input" ) ;
123
+
124
+ this . action = "Oh snap! Enter your department and try submitting again." ;
125
+ this . validate = false ;
126
+ }
127
+ if ( this . firstname == null || this . firstname == "" ) {
128
+ document . getElementById ( "firstname" ) . classList . add ( "invalid-input" ) ;
129
+
130
+ this . action = "Oh snap! Enter your first name and try submitting again." ;
131
+ this . validate = false ;
132
+ }
133
+ if ( this . lastname == null || this . lastname == "" ) {
134
+ document . getElementById ( "lastname" ) . classList . add ( "invalid-input" ) ;
135
+
136
+ this . action = "Oh snap! Enter your last name and try submitting again." ;
137
+ this . validate = false ;
138
+ }
139
+ if ( this . dob == null || this . dob == "" ) {
140
+ document . getElementById ( "dob" ) . classList . add ( "invalid-input" ) ;
141
+
142
+ this . action = "Oh snap! Enter your date of birth and try submitting again." ;
143
+ this . validate = false ;
144
+ }
145
+ if ( this . phone == null || this . phone == "" ) {
146
+ document . getElementById ( "phone" ) . classList . add ( "invalid-input" ) ;
147
+
148
+ this . action = "Oh snap! Enter your phone number and try submitting again." ;
149
+ this . validate = false ;
150
+ }
151
+ if ( this . address == null || this . address == "" ) {
152
+ document . getElementById ( "address" ) . classList . add ( "invalid-input" ) ;
153
+
154
+ this . action = "Oh snap! Enter your address and try submitting again." ;
155
+ this . validate = false ;
156
+ }
157
+ if ( this . city == null || this . city == "" ) {
158
+ document . getElementById ( "city" ) . classList . add ( "invalid-input" ) ;
159
+
160
+ this . action = "Oh snap! Enter your city and try submitting again." ;
161
+ this . validate = false ;
162
+ }
163
+ if ( this . state == null || this . state == "" ) {
164
+ document . getElementById ( "state" ) . classList . add ( "invalid-input" ) ;
165
+
166
+ this . action = "Oh snap! Enter your state and try submitting again." ;
167
+ this . validate = false ;
168
+ }
169
+ if ( this . country == null || this . country == "" ) {
170
+ document . getElementById ( "country" ) . classList . add ( "invalid-input" ) ;
171
+
172
+ this . action = "Oh snap! Enter your country and try submitting again." ;
173
+ this . validate = false ;
174
+ }
175
+ if ( this . zip == null || this . zip == "" ) {
176
+ document . getElementById ( "zip" ) . classList . add ( "invalid-input" ) ;
177
+
178
+ this . action = "Oh snap! Enter your zip and try submitting again." ;
179
+ this . validate = false ;
180
+ }
181
+
182
+ if ( this . userid == null || this . userid == "" ) {
183
+ document . getElementById ( "userid" ) . classList . add ( "invalid-input" ) ;
184
+
185
+ this . action = "Oh snap! Enter your userid and try submitting again." ;
186
+ this . validate = false ;
187
+ }
188
+ if ( this . usertype == null || this . usertype == "" ) {
189
+ document . getElementById ( "usertype" ) . classList . add ( "invalid-input" ) ;
190
+
191
+ this . action = "Oh snap! Enter your usertype and try submitting again." ;
192
+ this . validate = false ;
193
+ }
194
+ if ( this . company == null || this . company == "" ) {
195
+ document . getElementById ( "company" ) . classList . add ( "invalid-input" ) ;
196
+
197
+ this . action = "Oh snap! Enter your company and try submitting again." ;
198
+ this . validate = false ;
199
+ }
200
+
201
+
202
+ if ( ( ( < HTMLInputElement > document . getElementById ( 'chek' ) ) . checked == false ) && ( this . validate == true ) ) {
203
+ this . action = "Oh snap! Please accept the terms and conditions." ;
204
+ this . validate = false ;
205
+ }
206
+
43
207
44
- //this._httpWebService.createNewUser(this.userid, this.username, this.password, this.firstname, this.lastname, this.dob, this.phone, this.company, this.department, this.usertype, this.address, this.city, this.state, this.country, this.zip);
208
+ if ( this . validate ) {
209
+
210
+ this . _httpWebService . createNewUser ( this . userid , this . username , this . password , this . firstname , this . lastname , this . dob , this . phone , this . company , this . department , this . usertype , this . address , this . city , this . state , this . country , this . zip ) ;
211
+ this . _httpWebService . createNews ( window . localStorage . getItem ( 'user' ) , this . firstname , this . formattedDate , "Profile Update " , "Updated profile" ) ;
212
+ this . router . navigate ( [ 'signupsuccess' ] ) ;
213
+
214
+ }
45
215
}
46
216
}
0 commit comments