Uppercase Custom Validation Function

ChrisG

New member
I am using DaDaBIK version 7.3.2 released on 07-06-2016
PHP Version: 5.6.23
mysql version: 5.5.47-MariaDB
Web server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.6.23
Client: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0 OWASMIME/4.0500

Does anyone have a custom validation function that they have created to check field to make sure uppercase is used?
I have searched the forum and also the web and can't seem to find anything that would help a novice.

Any help or examples would be much appreciated!
 

eugenio

Administrator
Staff member
Hello,
I think this would be enough:

[pre]
function dadabik_validate_uppercase_myfield($parameters_ar){

if ($parameters_ar['myfield'] === strtoupper($parameters_ar['myfield'] )){
return true;
}
else{
return false;
}

}
[/pre]
 

ChrisG

New member
That appears to be working... but I think there needs to be some kind of "error" type message added somewhere right?
I noticed that when I do not enter all caps... there is a pink bar at the top but no message as to what is wrong. When I type all caps I get a green bar with "item correctly inserted" in it.
 

eugenio

Administrator
Staff member
Yes, from the instructions:


you also have to specify the error message in your language file (see /include/languages), using as a key nameofthefunction_not_valid; in this example, you would add a sentence to the $normal_messages_ar array having key = dadabik_validate_quantity_product_not_valid
 
Top