From 246a9934b0d82b594abded08ee5b4486928513c9 Mon Sep 17 00:00:00 2001 From: James O'Dwyer Date: Sat, 25 Oct 2014 12:06:56 -0400 Subject: [PATCH] Added email/password validation --- validator.js | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/validator.js b/validator.js index 860dab4..b060304 100644 --- a/validator.js +++ b/validator.js @@ -1,7 +1,35 @@ - //insert your code here - + + $(function(){ + var email_error = $("li:nth-child(1)") + var pw_8ch_error = $("li:nth-child(2)") + var pw_cap_error = $("li:nth-child(3)") + var pw_num_error = $("li:nth-child(4)") + email_error.hide(); + pw_8ch_error.hide(); + pw_cap_error.hide(); + pw_num_error.hide(); + + + var email = $("input[type='text']").val() + var password = $("input[type='password']") + var submit = $("input[type='submit']") + + var capPassword = $("input[type='password']") + + var emailValidation = /^([\w.-]+)@([\w.-]+)\.([a-zA-Z.]{2,6})$/i + + + submit.click(function(){ + if (email.match(emailValidation)) { + } else { + email_error.show() + } + + if ((password.length) < 8 ){ + pw_8ch_error.show() + } - //insert your code here + }) });