![]() |
I want to add space in validation for mobile number - 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: I want to add space in validation for mobile number (/showthread.php?tid=26118) |
I want to add space in validation for mobile number - El Forum - 01-06-2010 [eluser]shinokada[/eluser] At the moment validation is numeric. ButI want to add space in validation, so that it can accept 33 44 55 66 which common way of writing in Norway. How can I do it? Code: $this->form_validation->set_rules('telephone', 'Mobile/Telephone', 'trim|required|min_length[8]|max_length[12]|numeric'); I want to add space in validation for mobile number - El Forum - 01-06-2010 [eluser]wowdezign[/eluser] You could give the user four separate fields and then validate each one as numeric. Then when they submit the form, you could construct the number before inserting into the database. When repopulating the form, you'll need to undo the process. This method is my favorite. Others may have additional suggestions. I want to add space in validation for mobile number - El Forum - 01-06-2010 [eluser]davidbehler[/eluser] Use a callback: Code: $this->form_validation->set_rules('telephone', 'Mobile/Telephone', 'trim|required|min_length[8]|max_length[12]|callback__validate_phone_number'); |