Skip to content

Commit

Permalink
fix: the button is disabled when the input fields are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
upsaurav12 committed Jan 1, 2024
1 parent 35be979 commit bdcc421
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/assets/stylesheets/users.scss
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@
margin-top: 20px;
padding: 8px 25px;
}
.users-login-primary-button:disabled{
cursor: not-allowed;
}
.password-length {
display: flex;
flex-direction: row;
Expand Down
19 changes: 18 additions & 1 deletion app/views/users/sessions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<% if Flipper.enabled?(:recaptcha) %>
<%= recaptcha_tags %>
<% end %>
<%= f.submit t("login"), class: "btn primary-button users-login-primary-button" %>
<%= f.submit t("login"), class: "btn primary-button users-login-primary-button", disabled: true %>
<div class="users-text-container">
<span class="users-text"><%= t("users.ask_new_user") %></span>
<% unless Flipper.enabled?(:block_registration) %>
Expand All @@ -65,6 +65,23 @@
</div>
</div>
<script>
$(document).ready(()=>{
let email_input = $(".user-email-input");
let password_input = $(".users-password-input");
let login_button = $(".users-login-primary-button");

toggledButton = () =>{
let email_input_value = email_input.val().trim();
let password_input_value = password_input.val().trim();

if((email_input_value !== "") && (password_input_value !== "")){
login_button.prop("disabled",false);
}

}
email_input.on("input",toggledButton);
password_input.on("input",toggledButton);
})
$(".users-forgot-password-text").on('click', () => {
localStorage.setItem('Email', $(".user-email-input").val());
});
Expand Down

0 comments on commit bdcc421

Please sign in to comment.