-
-
Save kelmerp/6244022 to your computer and use it in GitHub Desktop.
Revisions
-
dbc-apprentice revised this gist
Aug 15, 2013 . 1 changed file with 19 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,22 @@ // shorthand for $(document).ready(); $(function(){ //Your code... $("form").submit(function(event) { event.preventDefault(); var array = $('form').serializeArray(); var emailRegex = /[A-z0-9]+@[A-z0-9]+\.[A-z]{2,4}/; var passwordRegex = /(.*[A-Z]+.*[0-9].*|.*[0-9].*[A-Z]+.*)/; var email = array[0].value; var password = array[1].value; console.log(email); console.log(password); if (!emailRegex.test(email)){ $('ul').append("<li>Must be a valid email address</li>"); } if ((password.length < 8) || (!passwordRegex.test(password))) { $('ul').append("<li>Password must have at least one numberic character (0-9)</li>"); $('ul').append("<li>Password must have at least one capital letter</li>"); $('ul').append("<li>Password must be at least 8 characters long</li>"); } }); }); -
Kevin Solorio created this gist
Aug 2, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ // shorthand for $(document).ready(); $(function(){ //Your code... }); 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="main.css"> <title>Form Validation</title> </head> <body> <form name="sign_up" action="#" method="post"> <label for="email">Email</label> <input type="text" name="email" /> <label for="password">Password</label> <input type="password" name="password" /> <button type="submit">Sign Up</button> <ul id="errors"></ul> </form><body> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="form-validator.js"></script> </body> </html> 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ ul#errors { color: red; }