How do I validate contact form fields?

Discussion in 'Web Design and Development' started by charl, Sep 22, 2009.

  1. charl macrumors newbie

    Sep 22, 2009
    Hi, many visitors type their email address wrong. How can I make sure this does not happen?
  2. notjustjay macrumors 603


    Sep 19, 2003
    Canada, eh?
    There are a bunch of different ways, both on the client (browser) side and the server side.

    On the client side, you can embed a Javascript that runs when the user clicks the form submit button. If the email address isn't valid, it could prevent the form from being submitted, pop up a dialog box and ask the user to re-enter a proper one. You can't rely on this alone, because some users don't browse with Javascript turned on.

    On the server side, the script processing the submitted form data can also check for invalid data, and if it's not good, then re-display the form, usually with a little message saying "please enter a valid email address".

    There's probably a ton of other ways, but these are two easy ones. You can Google for "form validation" or "email address validation" for lots of good tips and sample code.
  3. angelwatt Moderator emeritus


    Aug 16, 2005
    Are you wanting to validate the format of the email address, or the existence of the email address entered?
  4. charl thread starter macrumors newbie

    Sep 22, 2009
    I wanted to validate the format, because some users write stupid things there. Unfortunatelly I discoverd that my hosting does not allow PHP. (maybe because is so cheap :D ) . I googled a little and now I am using It's remotely hosted and I can add a field validation rule for my email address field.

Share This Page