I am building a form system and I have now started to work on the validation. My framework is CI so for the main part of my validation I have 'trim|required|htmlspecialchars' but what I was wanting to know:
A) What would be best to use for url and phone* inputs
B) What would you recommend that I use for client side validation – if any at all?
*I am from New Zealand so our phone numbers are 00 123 4567 or 1234567
CI’s validation is seriously shitty to deal with, especially when you want to make use of awesome jquery pluggins that make life simple.
For client side, I make use of a jquery plugin written by Jörn Zaefferer, it is pretty easy to get the hang of and is very customizable.
There are plenty of built in methods for standard things like urls, for NZ phone numbers I created some custom rules you can add to the additional-methods.js file that comes with the plugin.
As a side note, use these sparingly, unless you plan on dialing these numbers computationally just leave them as free text with a limit on length, there are a lot of variations on how people want to enter phone numbers and you’re better off not pissing people off by enforcing a rule that does not suit them / their number / addition of letters / + symbols / extentions etc