O'Reilly logo

Essential JavaScript™ for Web Professionals, Second Edition by Dan Barrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Project III: Letting the User Know What's Wrong

This final piece of code is nothing groundbreaking—we will be using methods that we covered earlier in the chapter. If the world were a perfect place, then the user would have filled out the form properly. However, this isn't always the case, so now that we have made the necessary checks for missing or erroneous data, we need to pass on what we have found to the user. We use a simple if statement to accomplish this.

// Letting the user know what was missed

     if ((requiredFieldsErrorMessage) || (pullDownErrorMessage) || (emailErrorMessage) || 
(areaCodeErrorMessage) || (zipCodeErrorMessage)) { . . . ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required