How to use ucwords on form variables ? |
[eluser]dhaulagiri[/eluser]
Hi friends, I have a field name "first_name" in my form. When posted to database I want it to be capitalize, please help me how do i do that ? This is a html form Code: <input type="text" style="text-transform: capitalize;" name="last_name" id="last_name" class="input-text" value="<?php echo ucwords($_POST['last_name']);?>"/> This is a controller Code: $data['last_name']= ucwords($_POST['last_name']); This didn't work. Pls help
[eluser]cchi[/eluser]
Are you trying to pass the posted value back to your form?? Cause if you are try to use the set_value() function of codeigniter. http://ellislab.com/codeigniter/user-gui...elper.html Code: <input type="text" name="quantity" value="<?php echo set_value('quantity', '0'); ?>" size="50" />
[eluser]Thorpe Obazee[/eluser]
Use it as a rule in the form validation: Code: $this->form_validation->set_rules('username', 'Username', 'ucwords|trim|required|min_length[5]|max_length[12]|xss_clean'); Quote:Note: You can also use any native PHP functions that permit one parameter, like trim, htmlspecialchars, urldecode, etc. |
Welcome Guest, Not a member yet? Register Sign In |