Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8545939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:54:19+00:00 2026-06-11T12:54:19+00:00

From what I can tell, my question should be pretty easy to answer for

  • 0

From what I can tell, my question should be pretty easy to answer for someone who encountered this issue before …

I have a signup form in rails which should highlight the fields that are not properly completed when the submit button is clicked (it should also show relevant error messages). The form contains only input fields and a checkbox. While the errors are properly displayed for each part of the form, the checkbox label is not properly highlighted in red when the user tries to submit the form whithout checking the checkbox.

What should I modify in my code to have the checkbox label highlighted when the checkbox is left unchecked?

This is the view code:

<%= form_for(@user) do |f| %>
<%= render 'shared/error_messages', object: f.object %>

  <%= f.label :name %>
  <%= f.text_field :name %>

  <%= f.label :email %>
  <%= f.text_field :email %>

  <%= f.label :password %>
  <%= f.password_field :password %>

  <%= f.label :password_confirmation, "Password confirmation" %>
  <%= f.password_field :password_confirmation %>

  <br>
  <%= f.check_box :terms_of_service %>
  <label_for="user_terms_of_service">I agree to the <%= link_to "Terms of Service", policies_path %>
  </label>
  <br><br>

  <%= f.submit "Create my account", :class => "btn btn-large btn-primary" %>
<% end %>

Also, this is what I can see with Firebug for the checkbox after the form is improperly submitted – the problem is that the div with class=”field_with_errors” is put before the checkbox label.

<br>
<input type="hidden" value="0" name="user[terms_of_service]">
<div class="field_with_errors">
<input id="user_terms_of_service" type="checkbox" value="1" name="user[terms_of_service]">
</div>
<label_for="user_terms_of_service">

Thank you for your help,
Alexandra

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:54:20+00:00Added an answer on June 11, 2026 at 12:54 pm

    The label syntax is not correct. Try

    <%= f.label :user_terms_of_service, "I agree to the #{link_to 'Terms of Service', policies_path}.".html_safe %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Variations of this question have been asked before, but it seems like the issue
From the question you can probably tell that I don't know much about code!
so from what i can tell, you have to specify artifacts and working directory
i have invoked blackberry calender from my application can anyone tell me how to
Can someone tell me how to catch parameters passed from URI in JSF's managed
NSDecimalNumber is a subclass of NSNumber, and from what I can tell, it implements
Can anybody tell how to retrieve data from database like that of Facebook's notification
Can anyone tell me how I can download a picture from a URL and
can anyone tell how to access MS SQL Server from objective c programatically
How can I tell if return() was called from within the included file. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.