title: Validate one form field or another form field based on a form selection, but not both at the same time
body: <p>How do you validate only check when PAYMENT_TYPE check is selected and also validate only creditcard when PAYMENT_TYPE creditcard is selected?</p>
  
  <pre><code>   class Order &lt; ActiveRecord::Base
      attr_accessible :check, :creditcard
      PAYMENT_TYPES = [ "Check", "Credit card" ]
      validates :creditcard, :presence =&gt; { :if =&gt; :creditcard? }
      validates :check, :presence =&gt; { :if =&gt; :check? }
  
       def creditcard?
       check == nil
       end
  
       def creditcard?
       creditcard == nil
       end
     end
  </code></pre>
  
  <p>form</p>
  
  <pre><code>  &lt;%= form_for(@order) do |f| %&gt;
  </code></pre>
  
  <p>...</p>
  
  <pre><code>    &lt;div class="field"&gt;
        &lt;%= f.label :pay_type %&gt;&lt;br /&gt;
        &lt;%= f.select :pay_type, Order::PAYMENT_TYPES,
        prompt: 'Select a payment method' %&gt;
      &lt;/div&gt;
      &lt;div id="creditcard"&gt;
        &lt;%= f.label :creditcard, class: "creditcard" %&gt;&lt;br /&gt;
        &lt;%=  f.text_field :creditcard, class: "creditcard" %&gt;
      &lt;/div&gt;
      &lt;div id="check"&gt;
        &lt;%= f.label :check, class: "check" %&gt;&lt;br /&gt;
        &lt;%=  f.text_field :check, class: "check" %&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>...</p>