Form field entry must start with cetrain characters

Discussion in 'HTML' started by Van Duijn, Jun 2, 2004.

  1. Van Duijn

    Van Duijn Guest

    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.
     
    Van Duijn, Jun 2, 2004
    #1
    1. Advertising

  2. Van Duijn

    Neal Guest

    On Wed, 2 Jun 2004 16:45:54 +0200, Van Duijn <> wrote:

    > 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.
     
    Neal, Jun 2, 2004
    #2
    1. Advertising

  3. "Van Duijn" <> wrote:

    > 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.)

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
     
    Jukka K. Korpela, Jun 3, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AtomicBob
    Replies:
    14
    Views:
    935
    Toby Inkster
    May 2, 2006
  2. NotGiven
    Replies:
    3
    Views:
    368
    Michael D. Kersey
    May 13, 2004
  3. GavMc
    Replies:
    4
    Views:
    360
    Evertjan.
    Sep 22, 2005
  4. NotGiven
    Replies:
    3
    Views:
    318
    Michael D. Kersey
    May 13, 2004
  5. Noozer
    Replies:
    2
    Views:
    278
    Dr John Stockton
    Aug 1, 2005
Loading...

Share This Page