diff --git a/app/assets/images/accept.png b/app/assets/images/accept.png new file mode 100644 index 0000000..89c8129 Binary files /dev/null and b/app/assets/images/accept.png differ diff --git a/app/assets/images/cross.png b/app/assets/images/cross.png new file mode 100644 index 0000000..1514d51 Binary files /dev/null and b/app/assets/images/cross.png differ diff --git a/app/assets/stylesheets/quadbase.css b/app/assets/stylesheets/quadbase.css index 2f248b9..351f616 100644 --- a/app/assets/stylesheets/quadbase.css +++ b/app/assets/stylesheets/quadbase.css @@ -1302,3 +1302,55 @@ a.tag_cloud_4 { font-size: 20px; line-height:4;} padding-top: 4px; width: 100%; } +u1, li { + margin:0; + padding:0; + list-style-type:none; + } + .invalid { + + background:url('/assets/cross.png') no-repeat 0 50%; + padding-left:22px; + line-height:24px; + color:#ec3f41; + } + .valid{ + background:url("/assets/accept.png") no-repeat 0 50%; + padding-left:22px; + line-height:24px; + color:#3a7d34; + } + + #pswd_info { + position:absolute; + bottom:55px; + bottom: -115px\9; + left:330px; + width:250px; + padding:15px; + background:#fefefe; + font-size:.875em; + border-radius:5px; + box-shadow:0 1px 3px #ccc; + border:1px solid #ddd; + } + #pswd_info h4 { + margin: 0 0 10px 0; + padding:0; + font-weight:normal; + } + #pswd_info::before { + content: "\25C4"; + position:absolute; + top:57px; + left:-4%; + font-size:16px; + line-height:14px; + color:#ddd; + text-shadow:none; + display:block; + } + #pswd_info { + display:none; + } + \ No newline at end of file diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 275ba47..18ae022 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -18,9 +18,17 @@

Email
<%= f.email_field :email %>

Password
- <%= f.password_field :password %>

+ <%= f.password_field :password, :id => 'pswd' %>

+
+

Password must meet the following requirements:

+ +
  • At least one letter
  • +
  • At least one number
  • +
  • At least 8 characters
  • +
    +

    Password Confirmation
    - <%= f.password_field :password_confirmation %>

    + <%= f.password_field :password_confirmation, :id => 'confirm' %>

    <% if @enable_recaptcha %>

    <%= recaptcha_tags :ssl => true %>

    @@ -41,15 +49,81 @@ <%# JS to enable/disable the submit button dependent on if the agree checkbox is checked %> <% content_for :javascript do %> <%= javascript_tag do %> -$('#agreement_checkbox').live('click', function() { - if ($('#agreement_checkbox').is(':checked')) { - $('#register_submit').removeAttr('disabled'); - $('#register_submit').removeClass('ui-state-disabled'); - } - else { - $('#register_submit').attr('disabled', 'disabled'); - $('#register_submit').addClass('ui-state-disabled'); +var len = false; +var letter = false; +var number = false; +var confirm = false; + +jQuery.fn.check_password = function(){ + if($('#confirm').val().length == 0){ + $('#register_submit').attr('disabled', 'disabled'); + $('#register_submit').addClass('ui-state-disabled'); + } + else if ($('#agreement_checkbox').is(':checked') &(len == true)& (letter == true) & (number == true)){ + $('#register_submit').removeAttr('disabled'); + $('#register_submit').removeClass('ui-state-disabled'); + + } + else if ($(len == false) | (letter == false) | (number == false)){ + $('#register_submit').attr('disabled', 'disabled'); + $('#register_submit').addClass('ui-state-disabled'); } + else { + $('#register_submit').attr('disabled', 'disabled'); + $('#register_submit').addClass('ui-state-disabled'); + } +} + +jQuery.fn.validate_password = function(){ + var password = $(this).val(); + //validate the length + if (password.length < 8) { + $('#length').removeClass('valid').addClass('invalid'); + len = false; + } else { + $('#length').removeClass('invalid').addClass('valid'); + len = true; + } + //validate letter + if (password.match(/[A-z]/)){ + $('#letter').removeClass('invalid').addClass('valid'); + letter = true; + } else { + $('#letter').removeClass('valid').addClass('invalid'); + letter = false; + } + //validate number + if (password.match(/\d/)){ + $('#number').removeClass('invalid').addClass('valid'); + number = true; + } else { + $('#number').removeClass('valid').addClass('invalid'); + number = false; + } +} + +$('#agreement_checkbox').click(function(){ + $(this).check_password(); +}); + +$('#pswd').keyup(function(){ + $(this).validate_password(); + $(this).check_password(); +}).focus(function(){ + $('#pswd_info').show(); +}).blur(function(){ + $('#pswd_info').hide(); }); +$('#confirm').keyup(function(){ + $(this).validate_password(); + $(this).check_password(); +}).focus(function(){ + $('#pswd_info').show(); +}).blur(function(){ + $('#pswd_info').hide(); +}); + + <% end %> <% end %> +