CodeIgniter Forums
form text field: treat default value as empty - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: form text field: treat default value as empty (/thread-54372.html)



form text field: treat default value as empty - El Forum - 09-06-2012

[eluser]SolarisDev[/eluser]
Hello Community,
I'm new to CodeIgniter and I have very simple problem. I have form field:
Code:
form_input("name", set_value("name", "New Category Name")
we have text field with value New Category name, now I neeed in validation to check that value is not empty but it shoul;d not be default value as well. In plain PHP I would do:
Code:
if($name == '' || $name == "New Category Name")
{
    return false;
}
How do I achieve that in CI, I have in controller function:
Code:
$this->form_validation->set_rules("name", "Category Name", "trim|required");

but that will just check if field is empty.

Thanks




form text field: treat default value as empty - El Forum - 09-06-2012

[eluser]siptik[/eluser]
http://ellislab.com/codeigniter/user-guide/libraries/form_validation.html#callbacks
helped you?



form text field: treat default value as empty - El Forum - 09-06-2012

[eluser]SolarisDev[/eluser]
yes it is, thanks a lot, I was looking in user guide but I probably didn't look enough.

Thanks