I just need to add a validation class that limits the numeric entry to 24.
Is this possible with the default CI authentication classes, or do I need to write my own authentication class?
There is no maximum or minimum comparison function in the Link validation rule , so you can just write your own validation function .
It is pretty simple. Something like this should work:
function maximumCheck($num) { if ($num > 24) { $this->form_validation->set_message( 'your_number_field', 'The %s field must be less than 24' ); return FALSE; } else { return TRUE; } } $this->form_validation->set_rules( 'your_number_field', 'Your Number', 'callback_maximumCheck' );
You can use the validation rule " greater_than[24]"
greater_than[24]
as an example
$this->form_validation->set_rules('your_number_field', 'Your Number', 'numeric|required|greater_than[24]');
Of course, you can simply create your own validation function and add it as an answer to the validation rule. See http://codeigniter.com/user_guide/libraries/form_validation.html#callbacks
Therefore you will have
... $this->form_validation->set_rules('mynumber', 'This field', 'callback_numcheck'); .... function numcheck($in) { if (intval($in) > 24) { $this->form_validation->set_message('numcheck', 'Larger than 24'); return FALSE; } else { return TRUE; } }
Source: https://habr.com/ru/post/1727160/More articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1727155/separate-repositories-for-separate-projects&usg=ALkJrhjLKXQKtDKLQOqe8mtXhfusyK-MhwFacebook create an event - phpGMap.NET does not display a map - c #Returning a two-dimensional array from an SQL query - sqlCreating a document format in MS Office format to display document properties - pythonHow can robots.txt ignore anything with action = history in it? - seoValidated Treeview nodes do not return in order - asp.netWhy is a cache object stored in a session when using AppFabric? - cachingЕсть ли способ повторно использовать шаблоны редактора и отображения в приложениях asp mvc? - asp.net-mvcjQuery (this) .val () does not return the value of the selected parameter - jqueryAll Articles