diff --git a/coffeevalidator.coffee b/coffeevalidator.coffee new file mode 100644 index 0000000..c24c649 --- /dev/null +++ b/coffeevalidator.coffee @@ -0,0 +1,10 @@ +$(".errors li").hide() + +$("form").submit(() -> + $(".errors li").hide() + text = $("input[type='text']").val(); + pass = $("input[type='password']").val(); + $(".errors li:nth-child(1)").show() if !text.match(/.*@.*\..*/) + $(".errors li:nth-child(2)").show() if pass.length<8 + $(".errors li:nth-child(3)").show() if !pass.match(/.*[A-Z].*/) + $(".errors li:nth-child(4)").show() if !pass.match(/.*[0-9].*/)); \ No newline at end of file diff --git a/coffeevalidator.js b/coffeevalidator.js new file mode 100644 index 0000000..35b6b2d --- /dev/null +++ b/coffeevalidator.js @@ -0,0 +1,24 @@ +// Generated by CoffeeScript 1.9.3 +(function() { + $(".errors li").hide(); + + $("form").submit(function() { + var pass, text; + $(".errors li").hide(); + text = $("input[type='text']").val(); + pass = $("input[type='password']").val(); + if (!text.match(/.*@.*\..*/)) { + $(".errors li:nth-child(1)").show(); + } + if (pass.length < 8) { + $(".errors li:nth-child(2)").show(); + } + if (!pass.match(/.*[A-Z].*/)) { + $(".errors li:nth-child(3)").show(); + } + if (!pass.match(/.*[0-9].*/)) { + return $(".errors li:nth-child(4)").show(); + } + }); + +}).call(this); diff --git a/index.html b/index.html index 7cf849d..76360b4 100644 --- a/index.html +++ b/index.html @@ -28,6 +28,6 @@