![]() |
Strip HTML tag - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Strip HTML tag (/showthread.php?tid=29179) Pages:
1
2
|
Strip HTML tag - El Forum - 04-01-2010 [eluser]Mithun[/eluser] What is the best method to strip htnl tags from the input? How can i remove the HTML tags while validating the input $this->form_validation->set_rules('description', 'Description', 'trim|xss_clean'); Do I need to add custom call back method to validation rules? Strip HTML tag - El Forum - 04-01-2010 [eluser]Sbioko[/eluser] No, you don't need to create a callback. To strip all HTML tags strip_tags function will help you. Something like this: Code: $clean = strip_tags($this->input->post('description')); Strip HTML tag - El Forum - 04-01-2010 [eluser]Mithun[/eluser] Thanjk you Sbioko, i wand something while form validation Strip HTML tag - El Forum - 04-01-2010 [eluser]Sbioko[/eluser] Oh, my mistake. Yeah, you need to create a callback. Sorry ;-) Call it for example strip_html_tags. Code: public function strip_html_tags($s) { Strip HTML tag - El Forum - 04-01-2010 [eluser]Mithun[/eluser] Again problem comes here, call back function need to be return true or false not the stripped string I have a call back function Code: public function html_clean($s) { and i use it like Code: $this->form_validation->set_rules('customer', 'Customer', 'trim|required|callback_html_clean|xss_clean'); Strip HTML tag - El Forum - 04-01-2010 [eluser]rogierb[/eluser] try something like : Code: $this->form_validation->set_rules('customer', 'Customer', 'trim|required|callback_html_clean['customer']|xss_clean'); Strip HTML tag - El Forum - 04-01-2010 [eluser]Mithun[/eluser] Is it better to have a MY_Contoller method ? Code: class MY_Contoller Strip HTML tag - El Forum - 04-01-2010 [eluser]Sbioko[/eluser] Guys, are you kidding? What are $_POST or MY_Controller. Did you try my solution? Before say or ask something, you should see in the user guide. Strip HTML tag - El Forum - 04-01-2010 [eluser]rogierb[/eluser] Hey, they guy wanted a true or false solution, I gave him that. Your solution does the trick, I know that. Don't get mad at me... ![]() Strip HTML tag - El Forum - 04-01-2010 [eluser]Sbioko[/eluser] I'm not mad. As I understood, he wants to cut out all the HTML tags, not validate(TRUE/FALSE). I gave him a solution, but he didn't try it. Maybe I misunderstand something, because English is a foreign language for me. |