Identifying Problem Fields

Changing the border of the input field to red is nice and all, but it would be better if we could make it a little clearer which field was the problem. In this example, you’ll learn how to set the label around the field to be red and bold, making it clear where the problem lies (Figure 7.7). Once again, the HTML and CSS files have not changed (they’re still Scripts 7.5 and 7.6). In Script 7.9, we’ve added a few lines of JavaScript to the previous Script 7.8 to help point out entry errors.

Figure 7.7. When there’s a problem, you can make the field’s label red and bold, as well as the field itself.

Script 7.9. This ...

Get JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.