CodeIgniter Forums
Form Validation - Alpha Characters and Spaces and Dashes - 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: Form Validation - Alpha Characters and Spaces and Dashes (/showthread.php?tid=47513)



Form Validation - Alpha Characters and Spaces and Dashes - El Forum - 12-12-2011

[eluser]drakeonfire[/eluser]
Hello,

I've done a bit of searching but can't really find what I need. If you can't tell I'm quite a newbie to CodeIgniter and I use DataMapper too.

I want to validate a form field to check if it only contains Alphabetical Characters (e.g. A-Z & a-z) and also spaces and dashes.

I thought the alpha form validation did this (except dashes), but apparently it doesn't accept spaces.

I know I could do it in a callback, but wanted to make sure it wasn't already a part of the system?

Also - is there a way to create a function / callback that can be used for the Controller and the Datamapper Models? Otherwise I'd have to create the function in both my controller and my model ... Sad

Thank you!