How do YOU validate data?
Sorry I know I've been asking loads of questions on this site, but I've just got a job doing web development and this is my first commercial experience.
I've been using regular expressions to validate form fields but I'm finding my code is getting too long to deal with. 4+ lines of code for each form field is excessive so I was wondering what the best way of doing form validation is? Is it best to make my own function with regualar expressions in to calculate things out, or should I use something else?
Re: How do YOU validate data?
the validation process is different for every type of field of course.
if the differences among all fields that u want to validate is very significant, then of course the way u treat the validation is different that will result in longer lines of codes
i think, there are many of validation samples in javascript and php
imho.... it'd be better if u let us know sample of fields that u want to validate, and what kind of validation is needed for those fields ...
such as :
field Name cannot contain digit
field username must be more than 6 char...
for all fields cannot be empty
CMIIW ...
:)
Re: How do YOU validate data?
For all validation that you do, you will have to make it object specific. There is no standard way of validating. For example. One field might be an email. In that case, you will need to look for @ and a period after that and letters after the period. If its a phone number, you will allow only numbers (sometimes parenthesis and a hyphen). Each field will be formatted differently, so how you validate all depends on the type of field that it is.