title: Using Model limitation in a view
body: <p>I trying to follow one of rails basic rules DRY (don't repeat yourself)
  I have the following model</p>
  
  <pre><code>class Micropost &lt; ActiveRecord::Base
    attr_accessible :content      
    belongs_to :user
    validates :content, :presence =&gt; true, :length =&gt; { :maximum =&gt; 140 }
    validates :user_id, :presence =&gt; true
    default_scope :order =&gt; 'microposts.created_at DESC'
  end
  </code></pre>
  
  <p>and in the form I'm limiting the textarea with Java script</p>
  
  <pre><code>f.text_area :content,
    :onKeyDown =&gt;"textCounter(micropost_content,counter,140)",
    :onKeyUP =&gt;"textCounter(micropost_content,counter,140)"
  </code></pre>
  
  <p>I want to use the maximum value from the validation in java script function.</p>
  
  <p>How do i do it?</p>