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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:56:13+00:00 2026-05-19T01:56:13+00:00

My Rails form code is as follows: <%= form_for(resource, :as => resource_name, :url =>

  • 0

My Rails form code is as follows:

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
        <%= f.text_field :f_name, :value => "First Name", :class => "clearField curved" %><br />
        <%= f.text_field :l_name, :value => "Last Name", :class => "clearField curved" %><br />
        <%= f.text_field :username, :value => "Username", :class => "clearField curved" %><br />
        <%= f.password_field :password, :value => "Password", :class => "clearField curved" %><br />
        <%= f.password_field :password_confirmation, :value => "Password", :class => "clearField curved" %><br />
        <%= f.text_field :email, :value => "Email Address", :class => "clearField curved" %><br />

    <div id="login_buttons">
        <%= f.submit "Sign in", :id => "login", :value => "Submit", :class => "curved" %>
        <%= f.submit "Sign in", :id => "register", :value => "Register", :class => "curved" %>
        <%= f.submit "Send Reset Instructions", :id => "pass-reset", :value => "Send Reset Instructions", :class => "curved"%>
        <a href="#" id="forgot-pw">Forgot pass?</a>
    </div>

<% end %>

What happens is when the page is loaded the first time, the user only sees the username & password field. Once they press ‘Register’ they then see the other fields. So what I would like to do is have form validation on both states. The login state (with just the username & password) and the registration state (with all the fields).

The HTML output produced is as follows:

<form accept-charset="UTF-8" action="/users/login" class="user_new" id="user_new" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="5B04HFtyauEPUigmXrIhi2jYvHJv47gvIgUbx64QQ0E=" /></div> 
        <input class="clearField curved" id="user_f_name" name="user[f_name]" size="30" type="text" value="First Name" /><br /> 
        <input class="clearField curved" id="user_l_name" name="user[l_name]" size="30" type="text" value="Last Name" /><br /> 
        <input class="clearField curved" id="user_username" name="user[username]" size="30" type="text" value="Username" /><br /> 
        <input class="clearField curved" id="user_password" name="user[password]" size="30" type="password" value="Password" /><br /> 
        <input class="clearField curved" id="user_password_confirmation" name="user[password_confirmation]" size="30" type="password" value="Password" /><br /> 
        <input class="clearField curved" id="user_email" name="user[email]" size="30" type="text" value="Email Address" /><br /> 

    <div id="login_buttons"> 
        <input class="curved" id="login" name="commit" type="submit" value="Submit" /> 
        <input class="curved" id="register" name="commit" type="submit" value="Register" /> 
        <input class="curved" id="pass-reset" name="commit" type="submit" value="Send Reset Instructions" /> 
        <a href="#" id="forgot-pw">Forgot pass?</a> 
    </div> 

I tried the following but it didn’t work:

$('#user_new').validate({
    debug: true,
    rules: {
        user_username: "required",
        user_email: {
            required: true,
            email: true
        }
    },
    messages: {
        user_username: "Please specify your name",
        user_email: {
            required: "We need your email address to contact you",
            email: "Your email address must be in the format of name@domain.com"
        }
    }
});

So would love any advice on how I can get this going.

Edit1: Any thoughts or possible solutions?

  • 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-19T01:56:14+00:00Added an answer on May 19, 2026 at 1:56 am

    This has been answered here:

    How do I do client-side form validation in jQuery?

    and originally here:

    How to use jquery.validate plugin in cakephp form

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a form_for code <%form_for :a,:url=>{:controller=>biz/a,:action=>save},:html =>{:multipart => true} do |f| %> .....
I have a quite average form in Rails, trough blog_kit <% form_for(@blog_post, :html =>
In my first rails app I'm trying to use form_for and fields_for to create
I have a rails form with a datetime_select field. When I try to submit
I am trying to create a form in Rails 2.2.2 that populates a field
So I've got a form in my Rails app which uses a custom FormBuilder
I have a rails model that validates uniqueness of 2 form values. If these
In rails, is it recommended to use form helpers? Internally, everything boils down to
In my Rails app, I have a form which redirects through a foreign service,
I'm working on a Rails app that sends data through a form. I want

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.