Form field entry must start with cetrain characters

V

Van Duijn

Hello,

How can I predefine that a form field entry should start with certain
characters, e.g. "10"? I want to use this in order to check if someone is
adding a legitimate membership code.

Thanks,

Martin.
 
N

Neal

Hello,

How can I predefine that a form field entry should start with certain
characters, e.g. "10"? I want to use this in order to check if someone is
adding a legitimate membership code.

Thanks,

Martin.

No way to do this in HTML.

If you can wait till they try to send, the CGI can be written to check
that. If you want an immediate correction (a popup saying "You've entered
an incorrect code" then Javascript can check the string. Advise asking
question in ng's suited to those topics.
 
J

Jukka K. Korpela

Van Duijn said:
How can I predefine that a form field entry should start with certain
characters, e.g. "10"?

You cannot.
I want to use this in order to check if
someone is adding a legitimate membership code.

Then you absolutely need to verify the code in the form handler
(server side), and may perform pre-checking client-side to help users fix
their errors more conveniently.

You _can_, and perhaps should, use a construct like
<input id="memcode" name="member" size="12" maxlength="12" value="10">
if the length of codes is 12 characters (just an example) and if all
codes currently begin with "10".

This saves a little typing from the user, but it also acts as an
additional hint of the input expected.

It by no means prevents the user from changing the field. And it might
even confuse or disturb some users. (They might e.g. cut and paste the
code from somewhere and fail to see that "10" is already prefilled.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,169
Latest member
ArturoOlne
Top