validation problem - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: validation problem (/showthread.php?tid=5180) |
validation problem - El Forum - 01-10-2008 [eluser]-spy-[/eluser] i was testing this code Code: <html> but error occured Code: Username what supposed to be the problem? validation problem - El Forum - 01-10-2008 [eluser]Sawariya[/eluser] Check in your validation function ... $field['username'] = "Username"; validation problem - El Forum - 01-10-2008 [eluser]xwero[/eluser] The validation values are only automatically set after the validation of the form field. If you want to add default values you have to make a loop where you add the values, for instance Code: $fields('username'=>'me'); validation problem - El Forum - 01-10-2008 [eluser]Sawariya[/eluser] That ok... here ur property name is not matching with ur validating field name validation problem - El Forum - 01-10-2008 [eluser]Peter Ivanov[/eluser] Hello is there a way that i can use the validation class to validate variables, is something like this possible Code: $var = 'is_this_email'; validation problem - El Forum - 01-10-2008 [eluser]tonanbarbarian[/eluser] yes you could do something like that Most of the rules that you can set such as required, matches, min_length, max_length, exact_length, valid_email, valid_ip, alpha, aplha_numeric, alpha_dash and numeric are just methods of the validation class that return a boolean value so if you wanted to test if an email address was valid for example you could Code: if ($this->validation->valid_email('[email protected]'))... validation problem - El Forum - 01-10-2008 [eluser]Peter Ivanov[/eluser] thanks tonanbarbarian, this is pretty usefull validation problem - El Forum - 01-10-2008 [eluser]Chris Newton[/eluser] You could also set the validation rules to check a callback function before the form will validate. Of course, this assumes you're pulling data from a form, and not just using the validation class by itself. $rules['var'] = "required|min_length[5]|callback_variable_check"; Refer to the 'setting validation rules' of the documentation; http://ellislab.com/codeigniter/user-guide/libraries/validation.html |