Practical application of regex in forms
Posted: Tue Oct 24, 2006 10:36 am
I wonder if anyone can point me to a good discussion about the practical application of regex in forms. Trying to validate every field in a form can be quite daunting and it seems necessary to make some choices about what is validated and to what degree. I'm interested in what experienced coders have to say about this, especially what solutions they have come to through experience.
Areas that are daunting to me are international formats like postal codes and phone numbers that vary hugely from country to country and ways to keep stuff out of forms that might break susequent code.
There are several issues of course, like trying to get good data by refusing obviously flawed imput (like a US phone number in the form xxx-xxx, while also accepting international numbers), text fields with numbers and extraneous characters (pretty straight forward), and security issues.
Any of these are easily handled if there are only one or two fields in the form, but when you have dozens of fields it seems impossible to check everything and decisions need to be made as to what is most important.
Thanks,
--Kenoli
Areas that are daunting to me are international formats like postal codes and phone numbers that vary hugely from country to country and ways to keep stuff out of forms that might break susequent code.
There are several issues of course, like trying to get good data by refusing obviously flawed imput (like a US phone number in the form xxx-xxx, while also accepting international numbers), text fields with numbers and extraneous characters (pretty straight forward), and security issues.
Any of these are easily handled if there are only one or two fields in the form, but when you have dozens of fields it seems impossible to check everything and decisions need to be made as to what is most important.
Thanks,
--Kenoli