|
@@ -63,7 +63,6 @@ class Validate
|
63
|
63
|
} elseif (strlen($ValidateVar) < $MinLength) {
|
64
|
64
|
return $Field['ErrorMessage'];
|
65
|
65
|
}
|
66
|
|
-
|
67
|
66
|
} elseif ($Field['Type'] === 'number') {
|
68
|
67
|
if (isset($Field['MaxLength'])) {
|
69
|
68
|
$MaxLength = $Field['MaxLength'];
|
|
@@ -91,7 +90,6 @@ class Validate
|
91
|
90
|
} elseif ($ValidateVar < $MinLength) {
|
92
|
91
|
return $Field['ErrorMessage']."$MinLength";
|
93
|
92
|
}
|
94
|
|
-
|
95
|
93
|
} elseif ($Field['Type'] === 'email') {
|
96
|
94
|
if (isset($Field['MaxLength'])) {
|
97
|
95
|
$MaxLength = $Field['MaxLength'];
|
|
@@ -111,7 +109,6 @@ class Validate
|
111
|
109
|
} elseif (strlen($ValidateVar) < $MinLength) {
|
112
|
110
|
return $Field['ErrorMessage'];
|
113
|
111
|
}
|
114
|
|
-
|
115
|
112
|
} elseif ($Field['Type'] === 'link') {
|
116
|
113
|
if (isset($Field['MaxLength'])) {
|
117
|
114
|
$MaxLength = $Field['MaxLength'];
|
|
@@ -131,7 +128,6 @@ class Validate
|
131
|
128
|
} elseif (strlen($ValidateVar) < $MinLength) {
|
132
|
129
|
return $Field['ErrorMessage'];
|
133
|
130
|
}
|
134
|
|
-
|
135
|
131
|
} elseif ($Field['Type'] === 'username') {
|
136
|
132
|
if (isset($Field['MaxLength'])) {
|
137
|
133
|
$MaxLength = $Field['MaxLength'];
|
|
@@ -151,22 +147,18 @@ class Validate
|
151
|
147
|
} elseif (strlen($ValidateVar) < $MinLength) {
|
152
|
148
|
return $Field['ErrorMessage'];
|
153
|
149
|
}
|
154
|
|
-
|
155
|
150
|
} elseif ($Field['Type'] === 'checkbox') {
|
156
|
151
|
if (!isset($ValidateArray[$FieldKey])) {
|
157
|
152
|
return $Field['ErrorMessage'];
|
158
|
153
|
}
|
159
|
|
-
|
160
|
154
|
} elseif ($Field['Type'] === 'compare') {
|
161
|
155
|
if ($ValidateArray[$Field['CompareField']] !== $ValidateVar) {
|
162
|
156
|
return $Field['ErrorMessage'];
|
163
|
157
|
}
|
164
|
|
-
|
165
|
158
|
} elseif ($Field['Type'] === 'inarray') {
|
166
|
159
|
if (array_search($ValidateVar, $Field['InArray']) === false) {
|
167
|
160
|
return $Field['ErrorMessage'];
|
168
|
161
|
}
|
169
|
|
-
|
170
|
162
|
} elseif ($Field['Type'] === 'regex') {
|
171
|
163
|
if (!preg_match($Field['Regex'], $ValidateVar)) {
|
172
|
164
|
return $Field['ErrorMessage'];
|
|
@@ -176,121 +168,245 @@ class Validate
|
176
|
168
|
} // while
|
177
|
169
|
} // function
|
178
|
170
|
|
179
|
|
- public function GenerateJS($FormID)
|
180
|
|
- {
|
181
|
|
- /*
|
182
|
|
- $ReturnJS = "<script type=\"text/javascript\" language=\"javascript\">\r\n";
|
183
|
|
- $ReturnJS .= "function formVal() {\r\n";
|
184
|
|
- $ReturnJS .= " clearErrors('$FormID');\r\n";
|
|
171
|
+ /**
|
|
172
|
+ * Extension Parser
|
|
173
|
+ *
|
|
174
|
+ * Takes an associative array of file types and extension, e.g.,
|
|
175
|
+ * $Archives = [
|
|
176
|
+ * '7z' => ['7z'],
|
|
177
|
+ * 'bzip2' => ['bz2', 'bzip2'],
|
|
178
|
+ * 'gzip' => ['gz', 'gzip', 'tgz', 'tpz'],
|
|
179
|
+ * ...
|
|
180
|
+ * ];
|
|
181
|
+ *
|
|
182
|
+ * Then it finds all the extensions in a torrent file list,
|
|
183
|
+ * organizes them by file size, and returns the "heaviest" match.
|
|
184
|
+ *
|
|
185
|
+ * That way, you can have, e.g., 5 GiB FASTQ sequence data in one file,
|
|
186
|
+ * and 100 other small files, and get the format of the actual data.
|
|
187
|
+ *
|
|
188
|
+ * todo: Incorporate into the main function (remove if statements first)
|
|
189
|
+ * todo: Make this work with a more robust object than $Tor->file_list()
|
|
190
|
+ */
|
|
191
|
+ public function ParseExtensions($FileList, $FileTypes)
|
|
192
|
+ {
|
|
193
|
+ # Make $Tor->file_list() output manageable
|
|
194
|
+ $UnNested = array_values($FileList[1]);
|
|
195
|
+ /*
|
|
196
|
+ $Sorted = usort($UnNested, function ($a, $b) {
|
|
197
|
+ return $b[0] <=> $a[0];
|
|
198
|
+ });
|
|
199
|
+ */
|
|
200
|
+ $TopTen = array_slice($UnNested, 0, 10); # Good
|
|
201
|
+ $Result = [];
|
|
202
|
+
|
|
203
|
+ print_r('<pre>');
|
|
204
|
+ var_dump($TopTen);
|
|
205
|
+ print_r('</pre>');
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+ foreach ($TopTen as $TopTen) {
|
|
209
|
+ $Extensions = explode('.', strtolower($TopTen[1]));
|
|
210
|
+ $Result = array_filter($Extensions, function ($a) {
|
|
211
|
+ foreach ($FileTypes as $FileType) {
|
|
212
|
+ in_array($a, $FileType);
|
|
213
|
+ }
|
|
214
|
+ });
|
|
215
|
+ /*
|
|
216
|
+ foreach ($FileTypes as $Key => $FileTypes) {
|
|
217
|
+ print_r('<pre>');
|
|
218
|
+
|
|
219
|
+ var_dump($UnNested);
|
|
220
|
+ var_dump( $FileTypes[$Key]);
|
|
221
|
+ print_r('</pre>');
|
|
222
|
+
|
|
223
|
+ }
|
|
224
|
+ */
|
|
225
|
+ }
|
|
226
|
+ /*
|
|
227
|
+ foreach ($TopTen as $TopTen) {
|
|
228
|
+ $Extensions = explode('.', strtolower($TopTen[1]));
|
|
229
|
+ #foreach ($FileTypes as $Key => $FileTypes) {
|
|
230
|
+ print_r('<pre>');
|
|
231
|
+ #$Result = (in_array($Extensions, $FileTypes)) ? $FileTypes[$Key] : false;
|
|
232
|
+ var_dump($Extensions);
|
|
233
|
+ var_dump(array_intersect($Extensions, $FileTypes));
|
|
234
|
+ print_r('</pre>');
|
|
235
|
+
|
|
236
|
+ #}
|
|
237
|
+ print_r('<pre>');
|
|
238
|
+ //var_dump(array_intersect($Extensions, $FileTypes));
|
|
239
|
+ //var_dump($Extensions);
|
|
240
|
+ print_r('</pre>');
|
|
241
|
+
|
|
242
|
+ }
|
|
243
|
+ */
|
|
244
|
+ print_r('<pre>');
|
|
245
|
+ #var_dump(array_intersect($UnNested, $FileTypes));
|
|
246
|
+ #print_r($Sorted);
|
|
247
|
+ print_r($Result);
|
|
248
|
+ print_r('</pre>');
|
|
249
|
+
|
|
250
|
+ /*
|
|
251
|
+ while ($Result === false) {
|
|
252
|
+ foreach ($UnNested as $Key => $UnNested) {
|
|
253
|
+ $Exploded = explode('.', strtolower($UnNested[1]));
|
|
254
|
+ foreach ($Needles as $Key => $Needle) {
|
|
255
|
+ $ID = array_search($Exploded, $Needle);
|
|
256
|
+ var_dump($Needle[$ID]);
|
|
257
|
+ }
|
|
258
|
+ $dump = array_filter($Exploded, function($s){
|
|
259
|
+ foreach ($Needles as $Type => $Extension) {
|
|
260
|
+ return array_search($s, $Extension);
|
|
261
|
+ }
|
|
262
|
+ });
|
|
263
|
+ #var_dump($dump);
|
|
264
|
+ /*
|
|
265
|
+ if (array_search($Needle, $Exploded, true)) {
|
|
266
|
+ $Result = $Needles;
|
|
267
|
+ #break;
|
|
268
|
+ }
|
|
269
|
+ }
|
|
270
|
+
|
|
271
|
+ }
|
|
272
|
+ */
|
|
273
|
+#var_dump($Result);
|
|
274
|
+ /*
|
|
275
|
+#do {
|
|
276
|
+ foreach ($UnNested as $UnNested) {
|
|
277
|
+ $Exploded = explode('.', strtolower($UnNested[1]));
|
|
278
|
+ #var_dump(in_array(vals($names), $Explode));
|
|
279
|
+
|
|
280
|
+ }
|
|
281
|
+/*
|
|
282
|
+ if (array_intersect($names, $Exploded)) {
|
|
283
|
+ $result = array_search($Exploded, $names);
|
|
284
|
+
|
|
285
|
+ }
|
|
286
|
+ *
|
|
287
|
+ }
|
|
288
|
+#} while ($result !== false);
|
|
289
|
+print_r($result);
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+*/
|
|
293
|
+ }
|
185
|
294
|
|
186
|
|
- reset($this->Fields);
|
187
|
|
- foreach ($this->Fields as $FieldKey => $Field) {
|
188
|
|
- if ($Field['Type'] === 'string') {
|
189
|
|
- $ValItem = ' if ($(\'#'.$FieldKey.'\').raw().value === ""';
|
190
|
|
- if (!empty($Field['MaxLength'])) {
|
191
|
|
- $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > '.$Field['MaxLength'];
|
192
|
|
- } else {
|
193
|
|
- $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > 255';
|
194
|
|
- }
|
195
|
|
- if (!empty($Field['MinLength'])) {
|
196
|
|
- $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < '.$Field['MinLength'];
|
197
|
|
- }
|
198
|
|
- $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
199
|
|
- } elseif ($Field['Type'] === 'number') {
|
200
|
|
- $Match = '0-9';
|
201
|
|
- if (!empty($Field['AllowPeriod'])) {
|
202
|
|
- $Match .= '.';
|
203
|
|
- }
|
204
|
|
- if (!empty($Field['AllowComma'])) {
|
205
|
|
- $Match .= ',';
|
206
|
|
- }
|
|
295
|
+ public function GenerateJS($FormID)
|
|
296
|
+ {
|
|
297
|
+ /*
|
|
298
|
+ $ReturnJS = "<script type=\"text/javascript\" language=\"javascript\">\r\n";
|
|
299
|
+ $ReturnJS .= "function formVal() {\r\n";
|
|
300
|
+ $ReturnJS .= " clearErrors('$FormID');\r\n";
|
207
|
301
|
|
208
|
|
- $ValItem = ' if ($(\'#'.$FieldKey.'\').raw().value.match(/[^'.$Match.']/) || $(\'#'.$FieldKey.'\').raw().value.length < 1';
|
209
|
|
- if (!empty($Field['MaxLength'])) {
|
210
|
|
- $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value/1 > '.$Field['MaxLength'];
|
211
|
|
- }
|
212
|
|
- if (!empty($Field['MinLength'])) {
|
213
|
|
- $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value/1 < '.$Field['MinLength'];
|
214
|
|
- }
|
215
|
|
- $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
216
|
|
- } elseif ($Field['Type'] === 'email') {
|
217
|
|
- $ValItem = ' if (!validEmail($(\'#'.$FieldKey.'\').raw().value)';
|
218
|
|
- if (!empty($Field['MaxLength'])) {
|
219
|
|
- $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > '.$Field['MaxLength'];
|
220
|
|
- } else {
|
221
|
|
- $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > 255';
|
222
|
|
- }
|
223
|
|
- if (!empty($Field['MinLength'])) {
|
224
|
|
- $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < '.$Field['MinLength'];
|
225
|
|
- } else {
|
226
|
|
- $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < 6';
|
227
|
|
- }
|
228
|
|
- $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
229
|
|
- } elseif ($Field['Type'] === 'link') {
|
230
|
|
- $ValItem = ' if (!validLink($(\'#'.$FieldKey.'\').raw().value)';
|
231
|
|
- if (!empty($Field['MaxLength'])) {
|
232
|
|
- $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > '.$Field['MaxLength'];
|
233
|
|
- } else {
|
234
|
|
- $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > 255';
|
235
|
|
- }
|
236
|
|
- if (!empty($Field['MinLength'])) {
|
237
|
|
- $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < '.$Field['MinLength'];
|
238
|
|
- } else {
|
239
|
|
- $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < 10';
|
240
|
|
- }
|
241
|
|
- $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
242
|
|
- } elseif ($Field['Type'] === 'username') {
|
243
|
|
- $ValItem = ' if ($(\'#'.$FieldKey.'\').raw().value.match(/[^a-zA-Z0-9_\-]/)';
|
244
|
|
- if (!empty($Field['MaxLength'])) {
|
245
|
|
- $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > '.$Field['MaxLength'];
|
246
|
|
- }
|
247
|
|
- if (!empty($Field['MinLength'])) {
|
248
|
|
- $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < '.$Field['MinLength'];
|
249
|
|
- }
|
250
|
|
- $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
251
|
|
- } elseif ($Field['Type'] === 'regex') {
|
252
|
|
- $ValItem = ' if (!$(\'#'.$FieldKey.'\').raw().value.match('.$Field['Regex'].')) { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
253
|
|
- } elseif ($Field['Type'] === 'date') {
|
254
|
|
- $DisplayError = $FieldKey.'month';
|
255
|
|
- if (isset($Field['MinLength']) && $Field['MinLength'] === 3) {
|
256
|
|
- $Day = '$(\'#'.$FieldKey.'day\').raw().value';
|
257
|
|
- $DisplayError .= ",{$FieldKey}day";
|
258
|
|
- } else {
|
259
|
|
- $Day = '1';
|
260
|
|
- }
|
261
|
|
- $DisplayError .= ",{$FieldKey}year";
|
262
|
|
- $ValItemHold = ' if (!validDate($(\'#'.$FieldKey.'month\').raw().value+\'/\'+'.$Day.'+\'/\'+$(\'#'.$FieldKey.'year\').raw().value)) { return showError(\''.$DisplayError.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
|
302
|
+ reset($this->Fields);
|
|
303
|
+ foreach ($this->Fields as $FieldKey => $Field) {
|
|
304
|
+ if ($Field['Type'] === 'string') {
|
|
305
|
+ $ValItem = ' if ($(\'#'.$FieldKey.'\').raw().value === ""';
|
|
306
|
+ if (!empty($Field['MaxLength'])) {
|
|
307
|
+ $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > '.$Field['MaxLength'];
|
|
308
|
+ } else {
|
|
309
|
+ $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > 255';
|
|
310
|
+ }
|
|
311
|
+ if (!empty($Field['MinLength'])) {
|
|
312
|
+ $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < '.$Field['MinLength'];
|
|
313
|
+ }
|
|
314
|
+ $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
|
315
|
+ } elseif ($Field['Type'] === 'number') {
|
|
316
|
+ $Match = '0-9';
|
|
317
|
+ if (!empty($Field['AllowPeriod'])) {
|
|
318
|
+ $Match .= '.';
|
|
319
|
+ }
|
|
320
|
+ if (!empty($Field['AllowComma'])) {
|
|
321
|
+ $Match .= ',';
|
|
322
|
+ }
|
|
323
|
+
|
|
324
|
+ $ValItem = ' if ($(\'#'.$FieldKey.'\').raw().value.match(/[^'.$Match.']/) || $(\'#'.$FieldKey.'\').raw().value.length < 1';
|
|
325
|
+ if (!empty($Field['MaxLength'])) {
|
|
326
|
+ $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value/1 > '.$Field['MaxLength'];
|
|
327
|
+ }
|
|
328
|
+ if (!empty($Field['MinLength'])) {
|
|
329
|
+ $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value/1 < '.$Field['MinLength'];
|
|
330
|
+ }
|
|
331
|
+ $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
|
332
|
+ } elseif ($Field['Type'] === 'email') {
|
|
333
|
+ $ValItem = ' if (!validEmail($(\'#'.$FieldKey.'\').raw().value)';
|
|
334
|
+ if (!empty($Field['MaxLength'])) {
|
|
335
|
+ $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > '.$Field['MaxLength'];
|
|
336
|
+ } else {
|
|
337
|
+ $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > 255';
|
|
338
|
+ }
|
|
339
|
+ if (!empty($Field['MinLength'])) {
|
|
340
|
+ $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < '.$Field['MinLength'];
|
|
341
|
+ } else {
|
|
342
|
+ $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < 6';
|
|
343
|
+ }
|
|
344
|
+ $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
|
345
|
+ } elseif ($Field['Type'] === 'link') {
|
|
346
|
+ $ValItem = ' if (!validLink($(\'#'.$FieldKey.'\').raw().value)';
|
|
347
|
+ if (!empty($Field['MaxLength'])) {
|
|
348
|
+ $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > '.$Field['MaxLength'];
|
|
349
|
+ } else {
|
|
350
|
+ $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > 255';
|
|
351
|
+ }
|
|
352
|
+ if (!empty($Field['MinLength'])) {
|
|
353
|
+ $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < '.$Field['MinLength'];
|
|
354
|
+ } else {
|
|
355
|
+ $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < 10';
|
|
356
|
+ }
|
|
357
|
+ $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
|
358
|
+ } elseif ($Field['Type'] === 'username') {
|
|
359
|
+ $ValItem = ' if ($(\'#'.$FieldKey.'\').raw().value.match(/[^a-zA-Z0-9_\-]/)';
|
|
360
|
+ if (!empty($Field['MaxLength'])) {
|
|
361
|
+ $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length > '.$Field['MaxLength'];
|
|
362
|
+ }
|
|
363
|
+ if (!empty($Field['MinLength'])) {
|
|
364
|
+ $ValItem .= ' || $(\'#'.$FieldKey.'\').raw().value.length < '.$Field['MinLength'];
|
|
365
|
+ }
|
|
366
|
+ $ValItem .= ') { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
|
367
|
+ } elseif ($Field['Type'] === 'regex') {
|
|
368
|
+ $ValItem = ' if (!$(\'#'.$FieldKey.'\').raw().value.match('.$Field['Regex'].')) { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
|
369
|
+ } elseif ($Field['Type'] === 'date') {
|
|
370
|
+ $DisplayError = $FieldKey.'month';
|
|
371
|
+ if (isset($Field['MinLength']) && $Field['MinLength'] === 3) {
|
|
372
|
+ $Day = '$(\'#'.$FieldKey.'day\').raw().value';
|
|
373
|
+ $DisplayError .= ",{$FieldKey}day";
|
|
374
|
+ } else {
|
|
375
|
+ $Day = '1';
|
|
376
|
+ }
|
|
377
|
+ $DisplayError .= ",{$FieldKey}year";
|
|
378
|
+ $ValItemHold = ' if (!validDate($(\'#'.$FieldKey.'month\').raw().value+\'/\'+'.$Day.'+\'/\'+$(\'#'.$FieldKey.'year\').raw().value)) { return showError(\''.$DisplayError.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
263
|
379
|
|
264
|
|
- if (empty($Field['Required'])) {
|
265
|
|
- $ValItem = ' if ($(\'#'.$FieldKey.'month\').raw().value !== ""';
|
266
|
|
- if (isset($Field['MinLength']) && $Field['MinLength'] === 3) {
|
267
|
|
- $ValItem .= ' || $(\'#'.$FieldKey.'day\').raw().value !== ""';
|
268
|
|
- }
|
269
|
|
- $ValItem .= ' || $(\'#'.$FieldKey.'year\').raw().value !== "") {'."\r\n";
|
270
|
|
- $ValItem .= $ValItemHold;
|
271
|
|
- $ValItem .= " }\r\n";
|
272
|
|
- } else {
|
273
|
|
- $ValItem .= $ValItemHold;
|
274
|
|
- }
|
275
|
|
- } elseif ($Field['Type'] === 'checkbox') {
|
276
|
|
- $ValItem = ' if (!$(\'#'.$FieldKey.'\').checked) { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
277
|
|
- } elseif ($Field['Type'] === 'compare') {
|
278
|
|
- $ValItem = ' if ($(\'#'.$FieldKey.'\').raw().value!==$(\'#'.$Field['CompareField'].'\').raw().value) { return showError(\''.$FieldKey.','.$Field['CompareField'].'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
279
|
|
- }
|
|
380
|
+ if (empty($Field['Required'])) {
|
|
381
|
+ $ValItem = ' if ($(\'#'.$FieldKey.'month\').raw().value !== ""';
|
|
382
|
+ if (isset($Field['MinLength']) && $Field['MinLength'] === 3) {
|
|
383
|
+ $ValItem .= ' || $(\'#'.$FieldKey.'day\').raw().value !== ""';
|
|
384
|
+ }
|
|
385
|
+ $ValItem .= ' || $(\'#'.$FieldKey.'year\').raw().value !== "") {'."\r\n";
|
|
386
|
+ $ValItem .= $ValItemHold;
|
|
387
|
+ $ValItem .= " }\r\n";
|
|
388
|
+ } else {
|
|
389
|
+ $ValItem .= $ValItemHold;
|
|
390
|
+ }
|
|
391
|
+ } elseif ($Field['Type'] === 'checkbox') {
|
|
392
|
+ $ValItem = ' if (!$(\'#'.$FieldKey.'\').checked) { return showError(\''.$FieldKey.'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
|
393
|
+ } elseif ($Field['Type'] === 'compare') {
|
|
394
|
+ $ValItem = ' if ($(\'#'.$FieldKey.'\').raw().value!==$(\'#'.$Field['CompareField'].'\').raw().value) { return showError(\''.$FieldKey.','.$Field['CompareField'].'\',\''.$Field['ErrorMessage'].'\'); }'."\r\n";
|
|
395
|
+ }
|
280
|
396
|
|
281
|
|
- if (empty($Field['Required']) && $Field['Type'] !== 'date') {
|
282
|
|
- $ReturnJS .= ' if ($(\'#'.$FieldKey.'\').raw().value!=="") {'."\r\n ";
|
283
|
|
- $ReturnJS .= $ValItem;
|
284
|
|
- $ReturnJS .= " }\r\n";
|
285
|
|
- } else {
|
286
|
|
- $ReturnJS .= $ValItem;
|
287
|
|
- }
|
288
|
|
- $ValItem = '';
|
289
|
|
- }
|
|
397
|
+ if (empty($Field['Required']) && $Field['Type'] !== 'date') {
|
|
398
|
+ $ReturnJS .= ' if ($(\'#'.$FieldKey.'\').raw().value!=="") {'."\r\n ";
|
|
399
|
+ $ReturnJS .= $ValItem;
|
|
400
|
+ $ReturnJS .= " }\r\n";
|
|
401
|
+ } else {
|
|
402
|
+ $ReturnJS .= $ValItem;
|
|
403
|
+ }
|
|
404
|
+ $ValItem = '';
|
|
405
|
+ }
|
290
|
406
|
|
291
|
|
- $ReturnJS .= "}\r\n";
|
292
|
|
- $ReturnJS .= "</script>\r\n";
|
293
|
|
- return $ReturnJS;
|
294
|
|
- */
|
295
|
|
- }
|
|
407
|
+ $ReturnJS .= "}\r\n";
|
|
408
|
+ $ReturnJS .= "</script>\r\n";
|
|
409
|
+ return $ReturnJS;
|
|
410
|
+ */
|
|
411
|
+ }
|
296
|
412
|
}
|