0

I'm trying to validate street number. I want to allow user to input "/" and "-" how can I do it with codeigniter forn validation.

$this->form_validation->set_rules('StreetNo', 'Street No', 'required|alpha_numeric');

The above code is the that I'm using at the moment. Could guys please help me with this?

Marius Flevie
  • 97
  • 2
  • 10
  • 1
    do your *really* need to do this; as some street numbers use other characters. –  May 20 '15 at 22:23
  • Find solution in [this answer](http://stackoverflow.com/questions/13982529/form-validation-rules-for-regex-match). And feel free to use [sof|google] search function. – Tpojka May 20 '15 at 22:26
  • Like @Dagon suggested, this isgenerally not a good idea. You will probably end up alienating people. – John Cartwright May 20 '15 at 22:35
  • @Dagon but some street addresses in Australia uses like this "24/2" so I want them to type only "/"and numbers. – Marius Flevie May 20 '15 at 22:39
  • I think what Dagon is getting at, is just leave it at 'required' and call it a day. Don't restrict too heavily if you don't have to. – castis May 20 '15 at 22:42
  • Exactly. It's going to get very complex if you want to introduce locale. I.e., if Australia is allowed a /, what about other countries that this isn't valid? – John Cartwright May 20 '15 at 22:43
  • Oh I get it now.... How stupid I'm am to think only about Australia... thanks guys and @Tpojka your answer is also really helpful for me in the future – Marius Flevie May 20 '15 at 22:46

0 Answers0