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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:03:50+00:00 2026-05-28T05:03:50+00:00

I have this form <div id=login> <h4>Please log in with your email address</h4> <%=

  • 0

I have this form

<div id="login">

  <h4>Please log in with your email address</h4>
  <%= form_for(@user, id: "login", remote: true) do |f| %>
    <% if @user.errors.any? %>
      <div id="error_explanation">
        <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>

        <ul>
        <% @user.errors.full_messages.each do |msg| %>
          <li><%= msg %></li>
        <% end %>
        </ul>
      </div>
    <% end %>

    <div class="field">
      <%= f.label :name %><br />
      <%= f.text_field :name %>
    </div>
    <div class="field">
      <%= f.label :email %><br />
      <%= f.text_field :email %>
    </div>
    <div class="field">
      <%= f.label :company %><br />
      <%= f.text_field :company %>
    </div>
    <div class="field">
      <%= f.label :phone %><br />
      <%= f.text_field :phone %>
    </div>
    <div class="field">
      <%= f.label :address %><br />
      <%= f.text_field :address %>
    </div>
    <div class="actions">
      <%= f.submit id: "signup_submit" %>
    </div>
  <% end %>
  <script>
      $("#signup_submit").bind("ajaxSend", function(){
           alert('start');
         }).bind("ajaxComplete", function(){
           alert('end');
         });
  </script>
</div>

So I have data-remote set to true, and I am having a hard time displaying the errors that otherwise work when it degrates to HTTP requests.

I am sure this is simple and would appreciate any help.

Thanks.

  • 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-05-28T05:03:51+00:00Added an answer on May 28, 2026 at 5:03 am

    First reorganize this so that the error_explanation div exists on the page (so you can populate it with an error message… hide it with CSS if you need to)

    <div id="error_explanation">
      <% if @user.errors.any? %>
        <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
    
        <ul>
        <% @user.errors.full_messages.each do |msg| %>
          <li><%= msg %></li>
        <% end %>
        </ul>
      <% end %>
    </div>
    

    Then you can add this bit of jQuery code to your existing <script> tag area:

    // a method for parsing the JSON response
    handle_ajax_error = function(response) {
      try { var responseText = jQuery.parseJSON(response.responseText); } catch(e) { var responseText = null; }
      if (responseText !== null) { 
        var responseMsg = responseText.error; 
      } else {
        responseMsg = 'There was an unknown error or the request timed out.  Please try again later';
      }
    
      return responseMsg;
    }
    
    // callback for the ajax error on the #login form
    $('#login').live('ajax:error', function(data, xhr, response){ 
      $('#error_explanation').html(handle_ajax_error(response));
    });
    

    And then this assumes that you have something like this in your controller response for the error:

    def create
      @user = User.create(params[:user])
      if @user.save
        redirect_to user_path(@user)
      else
        render :json => { :error => @user.errors.full_messages.to_sentence }, 
               :status => :unprocessable_entity
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this form: <form> <div class=box> <h1>Contact form :</h1> <label> <span>Typ: </span> <input
So I have this form <form> <div> <span class=form_t>I Want To Trade In <span
I have form like this: <div class=satu> <input type='text' size='1' maxlength='1' name='score[1][]' id='score[1][]'> </div>
I have form like this : <div id='add_field' class='locbutton'><a href='#' title='Add'>Add</a></div> <div id='remove_field' class='locbutton2'><a
I have a form that looks kind of like this: <div> <div class=contact> <h1>Person's
Okay so say I have a form element like this: HTML: <div class=form-item> <label>Current
I have a login form as below, I have tried doing this by onkeydown
Delayed too long with this issue. I have a index.php including form and login.php
Please help. I have page login/auth.gsp with the following code inside the body <div
Please, help me with one problem. I have this code, for submitting form via

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.