Created
December 15, 2012 21:31
-
-
Save 0xgdr/4299418 to your computer and use it in GitHub Desktop.
Lesson from Treehouse, using jquery.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function isValidEmail(email) { | |
| return email.indexOf("@") != -1; | |
| } | |
| // get all the inputs with the class of required | |
| var $required = $('.required'); | |
| function requiredValues() { | |
| var $values = new Array(); | |
| $required.each(function() { | |
| $values.push($(this).val()); | |
| }); | |
| return $values; | |
| } | |
| function containsBlanks() { | |
| var blanks = new Array(); | |
| $required.each(function() { | |
| blanks.push($(this).val() == ""); | |
| }); | |
| return $.inArray(true, blanks) != -1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Modifying Attributes</title> | |
| <style type="text/css"> | |
| .valid { | |
| color: green; | |
| border: 2px solid green; | |
| } | |
| .error { | |
| color: red; | |
| border: 2px solid red; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <p> | |
| <input type="text" class="required" id="name" value="Andrew"> | |
| </p> | |
| <p> | |
| <input type="text" class="required" id="company" value="Treehouse Island, Inc"> | |
| </p> | |
| <p> | |
| <input type="text" class="" id="phone" value="555-123-4567"> | |
| </p> | |
| <script type="text/javascript" src="jquery.js"></script> | |
| <script type="text/javascript" src="app.js"></script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment