From 25e2e72366d7286f2205480f14cd1ae6028ca857 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Tue, 21 Apr 2015 17:14:27 -0400 Subject: [PATCH] got username validation working --- public/less/install.less | 30 +++++++++++++++++++++++------- public/src/installer/install.js | 13 ++++++++++--- src/views/install/index.tpl | 8 ++------ 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/public/less/install.less b/public/less/install.less index 9385de3e86..a57d0e26c8 100644 --- a/public/less/install.less +++ b/public/less/install.less @@ -1,15 +1,31 @@ .btn, .form-control, .navbar { border-radius: 0; } .container { font-size: 18px; } body, small, p, div { font-family: "Roboto", sans-serif; } + .input-row { margin-bottom: 20px; -} -.input-row.active .input-field { - border-right: 5px solid #BF3E11; - padding-right: 20px; -} -.input-row.active .help-text { - display: block; + + &.active { + .input-field { + border-right: 5px solid #38B44A; + padding-right: 20px; + } + + .help-text { + display: block; + } + } + + &.error { + .input-field { + border-right: 5px solid #BF3E11; + padding-right: 20px; + } + + .help-text { + display: block; + } + } } .help-text { diff --git a/public/src/installer/install.js b/public/src/installer/install.js index fe86a5642e..f157f1d120 100644 --- a/public/src/installer/install.js +++ b/public/src/installer/install.js @@ -8,8 +8,13 @@ $('document').ready(function() { function setupInputs() { $('.form-control').on('focus', function() { + var parent = $(this).parents('.input-row'); + $('.input-row.active').removeClass('active'); - $(this).parents('.input-row').addClass('active'); + parent.addClass('active').removeClass('error'); + + var help = parent.find('.help-text'); + help.html(help.attr('data-help')); }); $('[name="username"]').on('blur', validateUsername); @@ -19,12 +24,14 @@ $('document').ready(function() { function validateUsername() { var $this = $(this), username = $this.val(), - help = $this.parents('.input-row').children('.help-text'); + parent = $this.parents('.input-row'), + help = parent.children('.help-text'); if (!utils.isUserNameValid(username) || !utils.slugify(username)) { + parent.addClass('error'); help.html('Invalid Username.'); } else { - help.html(''); + parent.removeClass('error'); } } }); \ No newline at end of file diff --git a/src/views/install/index.tpl b/src/views/install/index.tpl index 8d10af37d7..3687bd400f 100644 --- a/src/views/install/index.tpl +++ b/src/views/install/index.tpl @@ -53,18 +53,14 @@ -
- -
+
-
- Here is some sample help text. Username should be between 6 and 12 characters long. -
+