Example 11 - Invalid text boxes using hidden text

Example Start

required Indicates required fields.
Invalid: Names cannot contain numbers or punctuation characters
Invalid:You must supply a valid e-mail address for you to track any responses to the comment
Invalid: You must include a comment

Example End

Example Description

Example Features

Related Rules

HTML Source Code


<div class="inst">
    <img src="http://webaccessibility.cita.illinois.edu/media/examples/images/asterisk-blue.png" alt="required"/> Indicates required fields.
</div>

<div class="text">
    <label for="name">Name <span class="offscreen">Invalid: Names cannot contain numbers or punctuation characters</span></label>
    <div><input class="invalid" type="text" size="30" name="name" id="name" value="Mike4"/><img src="http://webaccessibility.cita.illinois.edu/media/examples/images/asterisk-red.png" alt=""/></div>
    <div class="invalid"><strong>Invalid:</strong> Names cannot contain numbers or punctuation characters</div>
</div>

<div class="text">
    <label for="email">E-mail <span class="offscreen">Invalid: you must supply a valid e-mail address for you to track any responses to the comment</span></label>
    <div><input class="invalid" type="text" size="25" name="email" id="email" value="joe.smith#nowhere.net"/><img src="http://webaccessibility.cita.illinois.edu/media/examples/images/asterisk-red.png" alt=""/></div>
    <div class="invalid"><strong>Invalid:</strong>You must supply a valid e-mail address for you to track any responses to the comment</div>
</div>

<div class="text">
    <label for="comment">Comment <span class="offscreen">Invalid: You must include a comment</span><img src="http://webaccessibility.cita.illinois.edu/media/examples/images/asterisk-red.png" alt=""/></label>
    <textarea class="invalid" rows="5" cols="50" id="comment" name="comment"></textarea>
    <div class="invalid"><strong>Invalid:</strong> You must include a comment</div>
</div>

CSS Code



span.offscreen  {
  position: absolute;
  top: -20em;
  left: -300em;
}

.invalid {
  color: red;
}

input.invalid,
textarea.invalid {
  color: black;
  background-color: #FFA0A0;
}


div.inst,
div.invalid {
  margin: 0;
  padding: 0;
  margin-left: 20px;
  margin-bottom: 1em;
}

div.text label {
  margin: 0;
  padding: 0;
  margin-left: 20px;
  display: block;
  font-size: 100%;
}

div.text input,
div.text textarea {
  margin: 0;
  padding: 0;
  margin-left: 20px;
  margin-bottom: .5em;
  font-size: 100%;
}

div.text img {
  margin: 0;
  padding: 0;
  padding-left: .25em;
}

input:active,
input:focus,
input:hover,
textarea:active,
textarea:focus,
textarea:hover {
  background-color: lightyellow;
  border-color: yellow;
}