Forward Thinking Form Validation

by Ryan Seddon

38 Reader Comments

Back to the Article
  1. The page has code:

    <li>              <label for=“email”>Email *</label>
                  <input type=“email” id=“email” name=“email” placeholder=“e.g. ryan@example.net” title=“Please enter a valid email” required />


    <span class=“invalid”>Please enter a valid email address e.g. ryan@example.com</span>
    <span class=“valid”>Thank you for entering a valid email</span>          </li>

    I believe to be accessible the code would need to be:

    <li>              <label>Email *
                  <input type=“email” id=“email” name=“email” placeholder=“e.g. ryan@example.net” title=“Please enter a valid email” required />


    <span class=“invalid”>Please enter a valid email address e.g. ryan@example.com</span>
    <span class=“valid”>Thank you for entering a valid email</span>          </label></li>

    so that the validation text is associated with the field it applies to.

    Copy & paste the code below to embed this comment.
  2. it helped me a lot …i wish in few days i will also be able to contribute to this

    Copy & paste the code below to embed this comment.
  3. Great post

    I am a believer in server and client validation (Just to be sure).

    Copy & paste the code below to embed this comment.
  4. I’ve written a jQuery plugin that’s about to enter production on a site that gets millions of visits per month.

    The intention of my script was just to make practical client-side validation easy using the HTML5 required and pattern attributes.

    Practical use of those features today was the primary aim, as opposed to a complete polyfill for the entire HTML5 form validation spec. As a consequence it handles “pattern” and “required” really well (supporting 14 verified browsers, including old browsers, iPhone, Android, and Palm WebOS), but it does not yet support all the custom input types, nor does it support the validation JavaScript API.

    If you’re interested in a jQuery validation plugin that’s usable today, this is it:

    http://ericleads.com/h5validate

    Copy & paste the code below to embed this comment.
  5. That aside, it’s nice to look forward and see how might use these features down the road.
    This article may give the impression that client-side validation obviates server-side validation

    Copy & paste the code below to embed this comment.
  6. Will be good when html5 support matures

    Copy & paste the code below to embed this comment.
  7. Very interesting article about validation.
    We can use now less js.

    Copy & paste the code below to embed this comment.
  8. This is quite good to use into code thus we don’t need to check JavaScript validation.

    input[type=‘text’]:focus{
      border: 1px solid skyblue;
      -moz-transition:border ease 1s;
      -webkit-transition: border ease 1s;
      -0-transition: border ease 1s;
    }

    Good way to style the input box.

    But some browser still not fully supports CSS3 and HTML5. For this reason we still need JavaScript to design the pages.

    Copy & paste the code below to embed this comment.