What could go wrong?
I have some questions about your validating methods.
So isValidAge only checks for String length.
So an age "dsiubv8iy" is valid, right?
isValidLname check if String is empty and does not contain "-".
So "@#$%^&*\n\n\r\t\u0001\u7123______________\r\n\r\u5fb5\n\r\n" is valid but "Skłodowska-Curie" is not?
isValidContNo check only for length so "\r\n\t\r\n\t\r\n\t\r" is a valid cont number?
When you validate data passed by user assume that the user is an crude idiot and will pass you anything. For example They might put "dsiubv8iy" as their age.
sunaina agarwal wrote:yes it is november 02nd 2013. hope you got it right.
Pawel's got it right; but you plainly haven't.
Have a look at his post again. Carefully.
PS: Please DontWriteLongLines. It makes your thread very hard to read, and it's actually bad coding practice. I've broken yours up this time.
Campbell Ritchie wrote:You can probably validate that sort of thing with a regular expression, but beware: What about places which don't have a street address? You might have Manor Farm, Great Badding. Name of place, and no street. You have to consider that a valid address here in Britain.
Being raised here in the colonies, we tend to forget that other places throughout the world don't always have what we would consider a "proper" address consisting of a house number, a street name and suffix, city, state, and zip (postal code). There was another post in the last day or so that described this problem -- the OP was required to enter his house number when in fact he did not have one. The program refused to let him move on until he corrected his "mistake". Thirty years ago we could get away with such short-sighted programming, but not in this day and age when you can get to any corner of the world in a handful of hours.
Oh, and the bit with the definition of 'm' -- I must have looked at that half a dozen times puzzling the problem you hinted at. Just as I was about to break down and read the simple date format notes the lightbulb came on and left me with another 'doh' moment.
Robert D. Smith wrote:Being raised here in the colonies, we tend to forget that other places throughout the world don't always have what we would consider a "proper" address consisting of a house number, a street name and suffix, city, state, and zip (postal code)...
Well, there are a few things that may be universal. In both the US and the UK, for example, every address (except possibly Buckingham Palace and 1600 Pennsylvania Avenue) has a postcode. Furthermore, if you know the postcode, things like city and state are usually redundant (although they may provide a useful "double-check").
In Madagascar, however (I have a friend whose wife is from there), you may well have an address like:
3rd house on the left, <Some village>
Conversely, even if you include ALL the things you're supposed to, viz:
The Pentagon, 1400 Defense Pentagon, Arlington, VA, 22211.
you've only narrowed it down to ≈31,000 people.
Basically, addresses, like people, are VERY difficult to rationalize 100%; so my advice is to treat it as free-form text unless there are components, like a postal code, that you know you can mandate.