@@ -13,6 +13,8 @@ const mJob = document.getElementById('mJob');
13
13
const mIncome = document . getElementById ( 'mIncome' ) ;
14
14
const childSchool = document . getElementById ( 'childSchool' ) ;
15
15
const childWork = document . getElementById ( 'childWork' ) ;
16
+ const studTrans = document . getElementById ( 'studTranscript' ) ;
17
+ const studImg = document . getElementById ( 'studImg' ) ;
16
18
17
19
18
20
forms . addEventListener ( 'submit' , e => {
@@ -58,6 +60,8 @@ const validateInputs = () => {
58
60
const mIncomeValue = mIncome . value . trim ( ) ;
59
61
const childSchoolValue = childSchool . value . trim ( ) ;
60
62
const childWorkValue = childWork . value . trim ( ) ;
63
+ const studImgValue = studImg . value ;
64
+ const studTransValue = studTrans . value ;
61
65
62
66
63
67
if ( studNameValue === '' ) {
@@ -166,10 +170,24 @@ const validateInputs = () => {
166
170
counter ++ ;
167
171
}
168
172
173
+ if ( studImgValue === '' ) {
174
+ setError ( studImg , "Sila muat naik gambar." ) ;
175
+ } else {
176
+ setSuccess ( studImg ) ;
177
+ counter ++ ;
178
+ }
179
+
180
+ if ( studTransValue === '' ) {
181
+ setError ( studTrans , "Sila muat naik transkrip." ) ;
182
+ } else {
183
+ setSuccess ( studTrans ) ;
184
+ counter ++ ;
185
+ }
186
+
169
187
console . log ( counter )
170
188
171
- if ( counter === 15 ) {
172
- window . location . href = "result.html" ;
189
+ if ( counter === 17 ) {
190
+ // window.location.href = "result.html";
173
191
174
192
localStorage . setItem ( 'studName' , studNameValue ) ;
175
193
localStorage . setItem ( 'studBirth' , studBirthValue ) ;
@@ -187,6 +205,24 @@ const validateInputs = () => {
187
205
localStorage . setItem ( 'childSchool' , childSchoolValue ) ;
188
206
localStorage . setItem ( 'childWork' , childWorkValue ) ;
189
207
208
+ const file = studImg . files [ 0 ] ;
209
+
210
+
211
+ if ( file ) {
212
+ const reader = new FileReader ( ) ;
213
+
214
+ reader . onload = function ( event ) {
215
+ const base64String = event . target . result ;
216
+
217
+ // Store the Base64 string in local storage
218
+ localStorage . setItem ( 'uploadedImage' , base64String ) ;
219
+ } ;
220
+
221
+ reader . readAsDataURL ( file ) ;
222
+ } else {
223
+ alert ( "No image uploaded." )
224
+ }
225
+
190
226
window . location . href = "result.html" ;
191
227
192
228
} else {
0 commit comments