javacript-validator-icm-formhandler

Gesponsorde koppelingen

PHP script bestanden

  1. javacript-validator-icm-formhandler

« Lees de omschrijving en reacties

Javascript voorbeeld

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<script src="validator.js" type="text/javascript"></script>

<script type="text/javascript">
<!--

window.onload = function(){
    // Add the elements to the validator
    Var Validator = new jsValidator();
    Validator.elmts = {
        name: {
            validator: 'IsString',
            msg: 'This field must be a valid string'
        },
        age: {
            validator: 'IsDigit',
            msg: 'This field must be a digit'
        },
        email: {
            validator: 'IsEmail',
            msg: 'This field must be a valid e-mail'
        },
        text: {
            validator: function(value){
                // The length must be greather than 10 characters
                return value.length > 10;
            },
            msg: 'This textarea must be longer than 10 characters'
        },
        select: {
            validator: 'regex',
            regex: /^option_[0-9]+$/,
            msg: 'This value must begin with option_ and end with a number'
        }
    }
    // Fire the validator
    Validator.init();
}


// -->
</script>


bijbehorende HTML:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<form action="#">
    <p>
        <label for="name">Name</label>
        <input type="text" id="name" name="name_field" />
    </p>
    <p>
        <label for="age">Age</label>
        <input type="text" id="age" name="age_field" />
    </p>
    <p>
        <label for="email">E-mail</label>
        <input type="text" id="email" name="email_field" />
    </p>
    <p>
        <label for="text">Text</label>
        <textarea id="text" name="description"></textarea>
    </p>
    <p>
        <label for="select">Selectfield</label>
        <select id="select" name="select_fied">
            <option value="option_1">One</option>
            <option value="option_2">Two</option>
            <option value="option_3">Three</option>
            <option>four</option>
        </select>
    </p>
    <p class="submit">
        <input type="submit" value="Submit" />
    </p>
</form>



Als FormHanlder gebruikt wordt:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?php

// include the class
include("fh3js.php");

// create a new FormHandler object
$form = new Fh3_JsValidator();

$form->setMask(
  "  <tr>\n".
  "    <td valign='top' align='right'>%title%</td>\n".
  "    <td valign='top'>%seperator%</td>\n".
  "    <td valign='top'>%field% %help% <span id='error_%name%'>%error%</span></td>\n".
  "  </tr>\n"
);

// some fields.. (see manual for examples)
$form->textField( "Name", "name", FH_STRING, 20, 40);
$form->textField( "Age", "age", FH_INTEGER, 4, 40);
$form->textField( "Functie", "functie", FH_STRING);
$form->selectfield('Select','select',array('a',1,3,5,7),FH_DIGIT,true);
$form->textarea('text','text',FH_TEXT);
$form->textarea('text','text2',_FH_TEXT);
// button for submitting
$form->submitButton();

// set the 'commit-after-form' function
$form->onCorrect('doRun');

// display the form
$form->flush();

// the 'commit-after-form' function
function doRun( $data )  
{

    echo "Hello ". $data['name'].", you are ".$data['age'] ." years old!";
}


?>



Het validatie bestand:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
// JS validator,Copyright (c) 2008 Arian Stolwijk, <http://aryweb.nl>, MIT Style License.

function jsValidator(){
    var Validator = {
    
        /**
         * Version of the jsValidator
         */
        varsion : '0.2a',
    
        /**
         * Settings
         */
        settings: {
            /**
             * The standard message
             */
            msg: 'This field is not correctly filled in',
    
            /**
             * The style of the message, any css/javascript style (eg. color, paddingLeft)
             */
            msgStyle: {
                paddingLeft: '5px',
                color: 'red',
                maxWidth: '300px'
            }
        },
    
    
        elmts : {
            // The Elements
        },    
        elmt: {
            // The field objects
        },
    
        /**
         * Initializes the validator
         */
        init: function(){
            for (var elem in this.elmts) { //for each element....
                // Skip to the next if the field doesn't extists
                if(document.getElementById(elem) == null){
                    continue;
                }
                if(document.getElementById(elem).tagName == 'input' || document.getElementById(elem).tagName == 'select' || document.getElementById(elem).tagName == 'textarea'){
                    continue;
                }
                this.addValidator(elem)
                        
            }
        },
        
        /**
         * Add a validator to a field, checks if the field is correct and calls the message functions
         * @param {Object} elmt
         */    
        addValidator: function(elem){
            this.elmt[elem] = document.getElementById(elem);
            if (typeof this.elmts[elem].validator != 'undefined'){
                if(typeof Validators[this.elmts[elem].validator] == 'function' || typeof this.elmts[elem].validator == 'function'){
                    this.elmt[elem].onblur = function(){
                        validator = Validator.elmts[elem].validator;
                        if (Validator.elmt[elem].tagName == 'SELECT') {
                            value = Validator.elmt[elem].options[Validator.elmt[elem].selectedIndex].value;
                        } else {
                            value = Validator.elmt[elem].value;
                        }
                        // Set error to true
                        var error = true;
                        if (validator == 'regex') {                        
                            // If there's a self made regex
                            if (Validators.regex(value + '', Validator.elmts[elem].regex)) {
                                // if the field is correct, set the error var to false
                                error = false;
                            }
                        }else if(typeof Validator.elmts[elem].validator == 'function'){
                            // There's a self made funtion
                            if(Validator.elmts[elem].validator(value)){
                                // if the field is correct, set the error var to false
                                error = false;
                            }
                        }else {
                            // The included validate methods
                            if (Validators[validator](value + '')) {
                                // if the field is correct, set the error var to false
                                error = false;
                            }
                        }
                        
                        // There's been an error
                        if(error == true){
                            // If thers
                            if(Validator.elmts[elem].msg){
                                var msg = Validator.elmts[elem].msg;
                            }else{
                                var msg = Validator.settings.msg;
                            }
                            Validator.inlineMsg(elem,msg);
                        }else{
                            Validator.hideMsg1(elem);
                        }
                    }
                }
            }
            
        },
            
        /**
         * Build the message and calls the function to show the message
         *
         * @param {Object} target
         * @param {Object} string
         */
        inlineMsg: function(target,string) {
            var targetdiv = document.getElementById(target);
            if (!document.getElementById('msg'+target)) {
                // Create two divs for the error message if the divs doesn't exists
                msg = document.createElement('span');
                msg.id = 'msg'+target;
                
                // give the msg div some style
                for (var msgStyle in this.settings.msgStyle) {
                    msg.style[msgStyle] = this.settings.msgStyle[msgStyle];
                }
                
                // add the msg element after the field
                targetdiv.parentNode.insertBefore(msg, targetdiv.nextSibling);
            }
            else {
                // The span elements already exists, so we can use them
                msg = document.getElementById('msg'+target);
            }
            // Put the error message into the messagecontent element
            msg.innerHTML = string;
            // Show the message
            this.showMsg(msg,target);
        },
        
        // This function calls the hideMsg method to create the same parameters like the showMsg method
        hideMsg1: function(elem){
            var elmt = document.getElementById('msg'+elem);
            this.hideMsg(elmt,elem);
        },
    
        /**
         * You can override this function with your own function
         * This function shows the message
         *
         * @param {Object}elmt : an instance of the message element
         * @param {String}elem : the fieldname
         */
        showMsg: function(elmt,elem){
            if (elmt) {
                elmt.style.display = 'inline';
            }
        },
        
        
        /**
         * This method hides the elemnt
         *
         * @param {Object} elmt : an instance of the message element
         * @param {String}elem : the fieldname
         */
        hideMsg: function(elmt,elem) {
            if (elmt) {
                // Hide the element when the element exists
                elmt.style.display = 'none';
            }
        }
    }
    
    return Validator;
}

/**
 * An apart object for the validation objects
 */
var Validators = {

    /**
     * Validators.regex
     *
     * This method handles a custom regular expression
     *
     * @param {Object} value
     * @param {Object} regex
     */
    regex: function(value,regex){
        return value.match(regex);
    },
    
    /**
     * Validators.IsString()
     *
     * Any string that doesn't have control characters (ASCII 0 - 31) but spaces are allowed
     *
     * @param string value: The string to check
     * @return bool
    */
    IsString: function(value){
         return value.match(/^[^\x01-\x1F]+$/);
    },

    /**
     * Validators._IsString()
     *
     * Public: same as IsString, only now the value is also valid if it is empty
     *
     * @param string value
     * @return bool
     */
    _IsString: function(value)
    {
        return value.length == 0 || this.IsString(value);
    },
    
    /**
     * Validators.IsAlpha()
     *
     * Public: only letters a-z and A-Z
     *
     * @param string value
     * @return bool
     */
    IsAlpha: function(value)
    {
        return value.match(/^[a-z]+$/i);
    },
    
    /**
     * Validators._IsAlpha()
     *
     * Public: same as IsAlpha, only now the value is also valid if it is empty
     *
     * @param string value
     * @return bool
     */
    _IsAlpha: function(value)
    {
        return value.length == 0 || this.IsAlpha(value);
    },
    
    /**
     * Validators.IsDigit()
     *
     * Public: only numbers 0-9
     *
     * @param string value
     * @return bool
     */
    IsDigit: function(value)
    {
        return value.match(/^[0-9]+$/);
    },
    
    /**
     * Validators._IsDigit()
     *
     * Public: same as IsDigit, only now the value is also valid if it is empty
     *
     * @param string $value
     * @return bool
     */
    _IsDigit: function(value)
    {
        return (value.length == 0 || this.IsDigit(value));
    },
    
    /**
     * Validators.IsAlphaNum()
     *
     * Public: letters and numbers
     *
     * @param string value
     * @return bool
     */
    IsAlphaNum: function(value)
    {
        return value.match(/^[a-z0-9]+$/i);
    },
    
    /**
     * Validators._IsAlphaNum()
     *
     * Public: same as IsAlphaNum, only now the value is also valid if it is empty
     *
     * @param string value
     * @return bool
     */
    _IsAlphaNum: function(value)
    {
        return value.length == 0 || this.IsAlphaNum(value);
    },
    
    /**
     * Validators.IsFloat()
     *
     * Public: only numbers 0-9 and an optional - (minus) sign (in the beginning only)
     *
     * @param string value
     * @return bool
     */
    IsFloat: function(value)
    {
        return value.match(/^-?([0-9]*\.?,?[0-9]+)$/);
    },
    
    /**
     * Validators._IsFloat()
     *
     * Public: same as IsFloat, only now the value is also valid if it is empty
     *
     * @param string value
     * @return bool
     */
    _IsFloat: function(value){
        return value.length == 0 || this.IsFloat(value);
    },
    
    /** Validators.IsInteger()
     *
     * Public: only numbers 0-9 and an optional - (minus) sign (in the beginning only)
     *
     * @param string $value
     * @return bool
     */
    IsInteger: function(value)
    {
        return value.match(/^-?[0-9]+$/);
    },
    
    /**
     * Validators._IsInteger()
     *
     * Public: same as IsInteger, only now the value is also valid if it is empty
     *
     * @param string value
     * @return bool
     */
    _IsInteger: function(value)
    {
        return value.length == 0 || this.IsInteger(value);
    },
    
    /**
     * Validators.IsFilename()
     *
     * Public: a valid file name (including dots but no slashes and other forbidden characters)
     *
     * @param string value
     * @return bool
     * @TODO: This method doesn't work
     */
    IsFilename: function(value)
    {
        return value.match(/{^[^\/\*\?\:\,]+$}/);
    },
    
    /**
     * Validators._IsFilename()
     *
     * Public: same as IsFilename, only now the value is also valid if it is empty
     *
     * @param string value
     * @return bool
     */
    _IsFilename: function(value)
    {
        return value.length == 0 || this.IsFilename(value);
    },
    
    /**
     * Validators.IsBool()
     *
     * Public: a boolean (case-insensitive "true"/"1" or "false"/"0")
     *
     * @param string value
     * @return bool
     */
    IsBool: function(value)
    {
        return value.match(/^true$|^1|^false|^0$/i);
    },
    
    /**
     * Validators._IsBool()
     *
     * Public: same as IsBool, only now the value is also valid if it is empty
     *
     * @param string value
     * @return bool
     */
    _IsBool: function(value)
    {
        return value.length == 0 || this.IsBool(value);
    },
    
    /**
     * a valid variable name (letters, digits, underscore)
     *
     * @param {string} value
     * @return bool
     */
    IsVariabele: function(value)
    {
        if(value == '_')
        {
            return false;
        }
        else if(value.match(/^[a-zA-Z_][a-zA-Z0-9_]*$/i))
        {
            return true;
        }
        else
        {
            return false;
        }
    },
    
    /**
     * same as IsVariabele, only now the value is also valid if it is empty
     *
     * @param string value
     * @return bool
     */
    _IsVariabele: function(value)
    {
        return value.length == 0 || this.IsVariabele(value);
    },
    
    
    /**
     * a valid password (alphanumberic + some other characters but no spaces. Only allow ASCII 33 - 126)
     *
     * @param {string} value
     * @return bool
     */
    IsPassword: function(value)
    {
        return value.match(/^[\x29-\x7E]+$/);
    },
    
    /**
     * same as IsVariabele, only now the value is also valid if it is empty
     *
     * @param string value
     * @return bool
     */
    _IsPassword: function(value)
    {
        return value.length == 0 || this.IsPassword(value);
    },

    /**
     * check for a valid url
     *
     * @param {string} value
     * @return bool
     */
    IsURL: function(value)
    {
        regex = /^((http|ftp|https):\/{2})?(([0-9a-zA-Z_-]+\.)+[a-zA-Z]+)((:[0-9]+)?)((\/([0-9a-zA-Z=%\.\/_-]+)?(\?[0-9a-zA-Z%\/&=_-]+)?)?)$/;
        return value.match(regex);
    },
    
    /**
     * same as IsURL, only now the value is also valid if it is empty
     *
     * @param string value
     * @return bool
     */
    _IsURL: function(value)
    {
        return value.length == 0 || this.IsURL(value);
    },
    
    /**
     * a valid email address (only checks for valid format: [email protected])
     *
     * @param {string} value
     * @return bool
     */
    IsEmail: function(value)
    {
        return value.match(/^[a-z0-9_\.-]+@([a-z0-9]+([\-]+[a-z0-9]+)*\.)+[a-z]{2,7}$/i);
    },
    
    /**
     * same as IsEmail, only now the value is also valid if it is empty
     *
     * @param string value
     * @return bool
     */
    _IsEmail: function(value)
    {
        return value.length == 0 || this.IsEmail(value);
    },
            
    /**
     * like IsString, but newline characters and tabs are allowed
     *
     * @param {string} value
     * @return bool
     */
    IsText: function(value)
    {
        return value.match(/^([^\x01-\x1F]|[\r\n\t])+$/);
    },
    
    /**
     * same as IsText, only now the value is also valid if it is empty
     *
     * @param string value
     * @return bool
     */
    _IsText: function(value)
    {
            return value.length == 0|| this.IsText(value);
    },
    
    /**
     * Check if the value does not contain any HTML
     *
     * @param {string} value
     * @return bool
     */
    NoHTML: function(value)
    {
        return value.replace(/(<([^>]+)>)/ig,"") == value && value.length > 0;
    },
    
    /**
     * same as NoHTML, only now the value is also valid if it is empty
     *
     * @param string value
     * @return bool
     */
    _NoHTML: function(value){
        return value.length == 0 || this.NoHTML(value);
    },
    
    /**
     * is a valid dutch postcode (eg. 9999 AA)
     *
     * @param {string} value
     * @return bool
     */
    IsPostcode: function(value)
    {
        return value.match(/^[1-9][0-9]{3} ?[a-zA-Z]{2}$/);
    },
    
    /**
     * same as IsPostcode, only now the value is also valid if it is empty
     *
     * @param string value
     * @return bool
     */
    _IsPostcode: function(value)
    {
       return value.length == 0 || this.IsPostcode(value);
    },
    
    /**
     * is a valid dutch phone-number
     *
     * @param {string} value
     * @return bool
     */
    IsPhone: function(value)
    {
        regex = /^[0-9]{2,4}[-]?[0-9]{6,8}$/;
        value = value.replace(' ','');
        value = value.replace('-','');
        return value.length == 10 && value.match(regex);
    },
    
    /**
     * same as IsPhone, only now the value is also valid if it is empty
     *
     * @param string value
     * @return bool
     */
    _IsPhone: function(value)
    {
        return value.length == 0 || this.IsPhone(value);
    },

    /**
     * check if it's a valid ip adres
     *
     * @param {string} value
     * @return bool
     */
    IsIp: function(ip )
    {
        return ip.match(/^\d{1,3}\.\d{1,3}\.\d{1,3}.\d{1,3}:?\d*$/);
    },
    
    /**
     * same as IsIp, only now the value is also valid if it is empty
     *
     * @param string value
     * @return bool
     */
    _IsIp: function(ip )
    {
        return value.length == 0 || this.IsIp(value);
    }
    
}


Als je het in combinatie met formhandler gebruiken wilt, heb je deze class nodig.
Je moet dan wel eerst ook formhandler downloaden: http://www.formhandler.net

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
140
141
142
<?php

/**
 * JS validator,Copyright (c) 2008 Arian Stolwijk, <http://aryweb.nl>, MIT Style License.
 */


include_once 'fh3/class.FormHandler.php';

class Fh3_JsValidator extends FormHandler {

    protected $jsvalidator;

    public function __construct($name=null,$action=null,$extra=null,$jsvalidator=true){
        parent::FormHandler($name,$action,$extra);
        
        $this->jsvalidator = $jsvalidator;
    }

    function
_setJS( $js, $isFile = false, $before = true, $eachform = false)
    {

        $this->_js[$before?0:1][$isFile?'file':'code'][] = $js;
        if(!$isFile){
            $this->_js[$before?0:1]['eachform']['code'][] = $eachform;
        }
else{
            $this->_js[$before?0:1]['eachform']['file'][] = $eachform;
        }
    }
    
    
    function
getJavascriptCode( $header = true )
    {

        static $return = array( 0 => false, 1 => false );;

        $s = $header ? 0 : 1;

        // if the javascript is not retrieved yet..
//        if( !$return[$s] )
//        {
            // generate the js "files" script

            $result = '';
            if( isset($this->_js[$s]['file']) && is_array($this->_js[$s]['file']) )
            {

                foreach( $this->_js[$s]['file'] as $key => $line )
                {

                    if($this->_js[$s]['eachform']['file'][$key] || !$return[$s]){
                        $result .= '<script language="javascript" type="text/javascript" src="'.$line.'"></script>'."\n";
                    }
                }
            }

            
            // generate the other js script
            if( isset($this->_js[$s]['code']) && is_array($this->_js[$s]['code']) )
            {

                $jscode = array();
                foreach( $this->_js[$s]['code'] as $key => $code){
                    if($this->_js[$s]['eachform']['code'][$key] || !$return[$s]){
                        $jscode[] = $code;
                    }
                }

                if(count($jscode) >= 1){
                    $result .= '<script language="javascript" type="text/javascript">'."\n";
                    $result .= implode($jscode);
                    $result .= "</script>\n";
                }
            }

            
            $return[$s] = true;
            return $result;
//        }

        return '';
    }

    
    
    public function getFields(){
        $fields = array();
        
        foreach($this->_fields as $key => $field){
            if(!empty($key)){
                $fields[] = $key;
            }
        }

        return $fields;
    }

    
    public function getField($fldName){
        if(!empty($this->_fields[$fldName])){
            return $this->_fields[$fldName][1];
        }
else{
            trigger_error('Dit veld bestaat niet');
        }
    }

    
    public function flush($return = false){
        $validator = array();
        if($this->jsvalidator){
            foreach($this->getFields() as $field){
                $field = $this->getField($field);
                
                if(!empty($field->_sValidator)){
                    $validator[$field->_sName] = $field->_sValidator;
                }
            }


            $this->_setJS('validator.js',true,true);
            static $validatorI = 0;
            $js = '    var Validator'.++$validatorI.' = new jsValidator();'.PHP_EOL.
                "    Validator".$validatorI.".settings.msg = '".$this->_text( 14 )."';".PHP_EOL.
                '    Validator'.$validatorI.'.showMsg = function(elmt,elem){'.PHP_EOL.
                "        document.getElementById('error_'+elem).innerHTML = '';".PHP_EOL.
                '        if (elmt) {'.PHP_EOL.
                "            elmt.style.display = 'inline';".PHP_EOL.
                '        }'.PHP_EOL.
                '    }'.PHP_EOL.
                
                '    Validator'.$validatorI.'.hideMsg = function(elmt,elem){'.PHP_EOL.
                "        document.getElementById('error_'+elem).innerHTML = '';".PHP_EOL.
                '        if (elmt) {'.PHP_EOL.
                "            elmt.style.display = 'none';".PHP_EOL.
                '        }'.PHP_EOL.
                '    }'.PHP_EOL.
                
                '    // Add the elements to the validator'.PHP_EOL.
                '    Validator'.$validatorI.'.elmts = {'.PHP_EOL;
            
            $aantal = count($validator);
            $i=1;
            foreach($validator as $field => $fldValidator){
                $js .= '        '.$field.': {'.PHP_EOL.
                    "            validator: '".$fldValidator."'".PHP_EOL.
                    '        }'.($i++ < $aantal ? ',':'').PHP_EOL;
            }

            $js .= '    }'.PHP_EOL.
            '    Validator'.$validatorI.'.init();'.PHP_EOL;
            $this->_setJS($js,false,false,true);
        }

        
        parent::flush($return);
    }
    
}

?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.