From e98d9c9b3e10f10ab0db414cf45dc0993feef838 Mon Sep 17 00:00:00 2001 From: Meagan Munch Date: Mon, 28 Nov 2016 11:23:24 -0500 Subject: [PATCH] Complete challenge --- validator.js | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/validator.js b/validator.js index 860dab4..5e7e59d 100644 --- a/validator.js +++ b/validator.js @@ -1,7 +1,38 @@ +$(document).ready(function(){ + $( "form input:text" ).keyup(function(){ + var val = this.value; - //insert your code here - -$(function(){ + var email = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i; - //insert your code here -}); + if(email.test(val)) { + $("ul li:nth-child(1)").hide(); + } else { + $("ul li:nth-child(1)").show(); + }; + + + }); + + $( "form input:password" ).keyup(function(){ + var password = this.value; + + if(password.length < 8){ + $("ul li:nth-child(2)").show(); + } else { + $("ul li:nth-child(2)").hide(); + }; + + if(/[A-Z]/.test(password)){ + $("ul li:nth-child(3)").hide(); + } else { + $("ul li:nth-child(3)").show(); + }; + + if(/[0-9]/.test(password)){ + $("ul li:nth-child(4)").hide(); + } else { + $("ul li:nth-child(4)").show(); + }; + }); + +}) \ No newline at end of file