Okay I have been teaching myself PHP form processing and validation.
What I’m trying to do is validate a form field that requires numbers. How do I do this?
I searched google and found some codes but nothing looks good.
The problem is this, I want the error message to appear in the form label.
So far this is what I have done but when I submit the form, even with a valid format number, I’m still getting error message that the number is not valid.
I finally figured it out, The problem was the number in the last curly bracket should be 4 not 3. I know it shows four in my post here but in the web page I noticed 3 and that should have been four.
That’s because the last sets of digits of the phone number is four not three. Eg: 5555.
Remember that not all phone numbers follow that format. My (UK) number is in the format xxxxx xxxxxx - but if you’re only catering for US residents then I guess that doesn’t matter
Hey Dan, what I did was added and example of how the number should be enter, this is near the input field and will give user the hint as to how they should enter the number. Eg: U.S only 555-555-555