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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:28:20+00:00 2026-06-13T14:28:20+00:00

I have a form in a Rails application with an invite code and a

  • 0

I have a form in a Rails application with an invite code and a block of credit card information. I’d like to be able to toggle between the two on the same page. Either the user provides an invite code or they input credit card information. It would be nice if a one or the other could be hidden when inactive (but not necessary). Here’s the relevant bits of the form:

  %hr

  %fieldset
    .control-group
      = label_tag :invite_code, nil, :class => "control-label"

      .controls
        = text_field_tag :invite_code

    .control-group
      .controls
        = f.hidden_field :stripe_token
        = f.hidden_field :last_4_digits

    - if @user.last_4_digits
      .control-group
        = label_tag :card, nil, :class => "control-label"
        .controls
          Using card ending with #{@user.last_4_digits}
          = link_to "(change)", "#"

  %hr

  %fieldset
    %noscript
      %p
        This form requires Javascript to use

    .control-group#credit-card{ :style => @user.last_4_digits ? "display:none" : "display:block" }
      #credit-card-errors{:style => "display:none"}
        #stripe-error-message.alert-message.block-message.error

      .control-group
        = label_tag :credit_card_number, nil, :class => "control-label"
        .controls= text_field_tag :credit_card_number, params[:credit_card_number], :class => "field", :disabled => true 

      .control-group
        = label_tag :cvv, "Security code (CVV)", :class => "control-label"
        .controls= text_field_tag :cvv, params[:cvv], :class => "small", :disabled => true 

      .control-group
        = label_tag :expiry_date, nil, :class => "control-label"
        .controls= date_select "", :expiry_date, {:discard_day => true, :order => [:month, :year], :use_month_numbers => true, :start_year => Date.today.year, :end_year => Date.today.year + 25, :disabled => true}, {:class => "input-small"}

      /empty
      %p
        Subscriptions will be billed $12 annually.

  %fieldset.form-submit
    = submit_tag 'Sign up', :class => 'btn btn-large btn-primary'

What is the sanest way to go about doing this?

  • 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-13T14:28:21+00:00Added an answer on June 13, 2026 at 2:28 pm

    Start with adding CSS ids or classes to your different field sets

    %fieldset#card
    ...
    %fieldset#invite
    ...
    

    use a CSS class called hidden

    .hidden {
      display:none;
    }
    

    and add it as default on the invite fieldset

    %fieldset#invite.hidden
    

    then add your “have an invite?” link

    %a{ :class => "have_invite" }
    

    then some jquery along these lines

    var show_invite_form = function(){
        $("#invite").removeClass("hidden");
        $("#card").addClass("hidden");
    };
    $(".have_invite").click(show_invite_form);
    

    And if you want it a bit more fancy you can start looking at jquerys fade and animate methods.

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

Sidebar

Related Questions

I have two tables in my rails application Categories and Projects. The relationship between
I would like to have Ajax form in Rails so i'm using form_remote_tag. The
I have a Rails form for email, and I would like to have auto-completion
We have the following code working for a complex rails form with checkboxes. I'm
I have some code to display a long list of languages inside Rails form
I'm trying to submit a Rails form with AJAX. I have some toggle on/off
I have a select list drop down in my Rails application, in the form
In my rails application I have two models called Kases and Notes. They work
In a Rails application, I have a particular form with many fields for editing
In my Rails 3 application I have the following form: <%= form_tag(/lounge/add_new_message, :id =>

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.