using a callback with a checkbox |
[eluser]browntown[/eluser]
Okay...i'm stumped. I have a form with a simple "do you authorize the release of this info" checkbox at the bottom of it. I want to display a custome error message: "You must authorize the release of this info..." instead of the standard "the authorized field is required". I'm using a callback to achieve the desired message. I cannot get the callback to fire properly. My checkbox looks like this: Code: $authorize = array('name'=>'authorize', 'id'=>'authorize', 'value'=>'accept', 'checked'=>FALSE, 'style'=>''); My callback: Code: function authorizeForm() I've tried a ton of variations to check if the checkbox is checked..." Code: if($_POST['authorize'] =="")... The weird thing is I can get the callback to fire if I do something like "if($this->input->post('authorize') == "accept")" and I check the checkbox...but if I do a "!= 'accept')"...it doesn't work. Any ideas?
[eluser]PauloBr[/eluser]
The callback function for checkbox, just execute if exists in "$_POST" array, so, just if checked. You can use "required" rule to verify this, no?
[eluser]browntown[/eluser]
yeah, it works if I used the "required" validation rule but I want to use a callback so I can customize the error message the user sees. My call back works if I check to see if the callback is equal to "accept"...but does not work if I check to see if it is not equal to "accept".
[eluser]Majd Taby[/eluser]
Go to http://ellislab.com/codeigniter/user-gui...ation.html and search for 'Setting Custom Error Messages'
[eluser]browntown[/eluser]
I know how to set custom error messages. I can set custom error messages fine if the checkbox equals "accept"...but it doesn't seem to work if the checkbox does not equal "accept".
[eluser]Majd Taby[/eluser]
ah, i'm sorry i didn't see that in your first post. To be honest I use my own form library, i'm not exactly sure how the helper and the validation library does it. |
Welcome Guest, Not a member yet? Register Sign In |