how to remove special characters - 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: how to remove special characters (/showthread.php?tid=42929) |
how to remove special characters - El Forum - 06-23-2011 [eluser]Wondering Coder[/eluser] hello to everyone just would like to ask how to remove this: -, [], / or any special characters in my input tried setting rules in validation using xss_clean but it still it save those character. e.g input: 1111-1-1111 = must only save 111111111 2222/2/2222 = must only save 222222222 2222#222#22 = must only save 222222222 etc…. how to remove special characters - El Forum - 06-24-2011 [eluser]Anonymous[/eluser] Use a callback on the input field. Then in the callback function use a regex. how to remove special characters - El Forum - 06-24-2011 [eluser]boltsabre[/eluser] sounds good to me... but make sure you do all your other validation before you make your call back. i.e. Code: $this->form_validation->set_rules('phoneNumber', 'Phone Number', 'trim|required|min_length[8]|myCustomCallBack As regex can be quiet taxing in processing power/time. Get your input as close to validated before applying your regex to save a little overhead. It may seem trivial now, but it's a good habit to get into, especially for larger applications and complex regex stuff |