-
Notifications
You must be signed in to change notification settings - Fork 1
Validation Client side
schnoog edited this page Dec 29, 2017
·
1 revision
The validation of input strings is performed by the jQuery plugin JQUERY-FORM-VALIDATOR
In order to use this plugin, you need to add a tag to each form element you want to validate, for example data-validation="required numeric" and if a range is defined also f.e. data-validation-length="min4"
Ensure that you have enabled late binding of the javascript file in your pages php
$pagedata['footincludes']['js'][]= 'form-validator/jquery.form-validator.min.js';
To interact with the server side validation class, a php interface function was written:
$valoutput = getFormvalidatorString($validationstring,$preset='',$onlypreset='')
The $validationstring should be exactly like on the server side (f.e. 'required|minlength[4]')
The function output should be placed with the control html f.e.:
<input id="myid" -$valoutput- >
Example Validation Input
<input id="myid" data-validation="required numeric" data-validation-length="min4" />
Example Validation Call
$('#myid' ).validate(function(valid, elem) {
if (valid) {
console.log('It is Valid');
} else {
console.log('It is Invalid');
}
} );
The result in this case would be true.