Home Disabled Button if Textbox nil Ruby on Rails / Devise / Simple Form
Reply: 0

Disabled Button if Textbox nil Ruby on Rails / Devise / Simple Form

user761
1#
user761 Published in April 26, 2018, 5:29 pm

I am trying to have a class change if the text field of my Simple_form is empty/nil and using ruby not jquery to do so.

My goal is to have a button disabled if the user has not put any text in and allow them to comment once they have. <%= simple_form_for([@message, @message.comments.build]) do |f| %>

  <div class="field">
    <%= f.input :content, label: "Reply" %>
  </div>

  <% if @message.comments.present? %>
    <%= f.button :submit, class: "ui disabled button" %>
  <% else %>
    <%= f.button :submit, class: "ui green button" %>
  <% end %>

<% end %>
</div>

Let me know if I am heading the right direction with this?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.530376 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO