Hello, I have a client that is needing a form on his webpage and I usually use a PHP form that I've found some time ago. However, this client is wanting a form that recognizes certain numbers entered into the form and tells you whether they are valid or not. For instance, You have your usual fields: NAME: EMAIL: But then you have another field for an Extension number that refers to an affiliate kind of like a phone extension. So the field is: EXTENSION: He wants it to recognize if you have entered an incorrect number in the field. For instance, the available options may be: 152, 153, 154 but say you enter 182 and hit submit. The redirect page would then tell you that it wasn't a valid choice. I know this could be remedied using a drop down list but he doesn't want that. He wants them to type it in. Any ideas? Any good form scripts? Thanks!
You can do it client side with JS or server side with PHP. Most people will tell you JS is better. I prefer the PHP.
If it is just a few numbers you can use PHP and something like: Repeating that for each of the numbers. You can also build an array of the numbers and check the submitted number agnist those values.
Well, I would want it to recognize the numbers that are correct rather than the incorrect ones... because they could type anything in.
You could use the select tag in HTML, this way you can set the only numbers that are allowed. You would then need tho set up a PHP script that checks the data when it has been sent; I would probably advise setting up an array. This is what the HTML would look like (from w3schools): <select> <option>Volvo</option> <option>Saab</option> <option>Mercedes</option> <option>Audi</option> </select> HTML: If you need help with the PHP contact me at
You would put the correct numbers in the array or in the not exactly = to part of the script. I think you may be in warer over your head on this one. May I suggest you hire someone to do this for you. Not I am not offerring.
If these phone ext need not to be secure, then how about loading your form with the valid values loaded too,something like: echo "<script type='text/javascript'>var valid_ext=new Array(152, 153, 154... Your client could type any numbers in the phone ext field of the form. Whenever that number mismatch the valid_ext, rise a javascript error alert to reset that field. This way, your form's phone ext field shall always be valid when sent, right? Regards,
That might work... but the issue is this: he wants to prevent leads from being able to get to the second page without knowing an extension number. For instance, he has people under him that provide leads and those leads get extension numbers that corresponds to their referrer. Therefore, the lead would get the number from the referrer and enter it in if or when they visit the page. If the options are there for them to see, like in a dropdown select, then they could just choose anything in the list and get to the next page. I mean he doesnt want to password protect crap or do advanced encryption and crap like that. Just something relatively simple like I've mentioned. I'm just not sure how to do it.
Secure ext phone numbers they are then: can not be preloaded to the form. The solution might be the one Colbyt has offered, only without intermediate (redirection to) error page. So there are only 2 pages to go: 1) the same (form) page, being invalidated all the time. 2) the inside/ target page, after ext phone numbers validated. Interesting. It is like trying 3 digits combination keys of your luggage: stay out or in, but no jail Ajax? It shall check validity after one has typed 3 digits ext phone numbers to your server, without page redirection. This scenario might be annoying (not risky), at times of high traffic, just imagine...