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 7806083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:25:09+00:00 2026-06-02T02:25:09+00:00

Currently when there is a validation error, a div with class=field_with_errors gets rendered in

  • 0

Currently when there is a validation error, a div with class="field_with_errors" gets rendered in my form:

<form method="post" action="/users" accept-charset="UTF-8">
  <div class="field_with_errors">
    <input id="user_email" type="text" value="tom@test.com" name="user[email]">
  </div>
  <input id="user_password" type="password" value="mypass" size="30" name="user[password]">
  <input id="user_submit" type="submit" value="Submit" name="commit">
</form>

Without the use of an additional gem and in a Rails 3 environment, is there a way to modify how the validation error is rendered? For example, I want the validation error div to be rendered after the input tag with the error:

<input id="user_email" type="text" value="tom@test.com" name="user[email]"><div class="field_with_errors"></div>

Also, is there a way to render a specific error? If it was an email error, then render the div after the input textbox and produce a “Re-enter your email” message.

(Most of the searches I have done so far use gems as the solution.)

  • 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-02T02:25:11+00:00Added an answer on June 2, 2026 at 2:25 am

    1.You can remove the field_with_errors wrapper by overriding ActionView::Base.field_error_proc.It can be done by putting this in your config/application.rb:

    config.action_view.field_error_proc = Proc.new { |html_tag, instance| "#{html_tag}".html_safe }
    

    Refer

    Rails 3: "field-with-errors" wrapper changes the page appearance. How to avoid this?

    2.You can display error message on specific field.

    <input id="user_email" type="text" value="tom@test.com" name="user[email]">
    <% if @user.errors.on(:email).present? %>
       <span class="error">Re-enter your email(or)<%= @user.errors.on(:email) %></span>
    <% end %>
    

    Then in your CSS

    .error {
      color: red;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$('form[id^=comment_add]').live(submit,function() { var id= this.id.replace(/[^\d]+/g,''); $.post($(this).attr('action'), $(#comment_add+id).serialize(), function(data) { /*do something*/ }) .error(function(jqXHR, textStatus,
There is currently this Prototype code that does a PUT: new Ajax.Request(someUrl, { method:
I have a form in which validation error message needs to be displayed below
Currently there are 2 pages in a jsp file: one of them displays the
Is there currently any easy way to set up a YAWS web server in
There Currently is a local debate as to which code is more readability We
Is there currently a way to subscribe to an event of a wrapped set,
I am working on a project currently where there are SQL strings in the
I want to start findBugs on existing project (on command line there are currently
As far as I know, there is currently no JAXB implementation which would work

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.