-
-
Save GeoffCrittenden/6729100 to your computer and use it in GitHub Desktop.
Revisions
-
GeoffCrittenden revised this gist
Sep 27, 2013 . 1 changed file with 27 additions and 1 deletion.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,31 @@ // shorthand for $(document).ready(); $(function(){ //Your code... var regexEmail = /.+@.+\..{2,}/ var regexPassLength = /.{8,}/ var regexPassCap = /[A-Z]+/ var regexPassNum = /\d+/ $('form').on('submit', function(e) { e.preventDefault(); var email = regexEmail.exec(this[0].value); var passLength = regexPassLength.exec(this[1].value) var passCap = regexPassCap.exec(this[1].value) var passNum = regexPassNum.exec(this[1].value) console.log(email); console.log(passLength); console.log(passCap); console.log(passNum); if ( email === null ) { $('#errors').append("<li>Email format invalid</li>"); }; if (passLength === null) { $('#errors').append("<li>Password needs to be at least 8 characters long</li>"); }; if (passCap === null) { $('#errors').append("<li>Password needs at least one capital letter</li>"); }; if (passNum === null) { $('#errors').append("<li>Password needs at least one number</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; }