title: format html input with thousand separator with Yii - jquery
body: <p>So I have these rule in a model in Yii:</p>
  
  <pre><code>array('svalue','numerical'),
  </code></pre>
  
  <p>As these are numbers (and later they will be used for calculations),
  I'd like to save it as number.</p>
  
  <p>The client though is asking that numbers be formatted with a comma ',' separator for thousands (1,200 = thousand two hundred). My predecessor on the project used</p>
  
  <pre><code>$.fn.digits = function(){
      return this.each(function(){
          $(this).keyup(function(){
              $(this).val( $(this).val().replace(/,/g,"").replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") );
          });
      })
  }
  </code></pre>
  
  <p>and I added keydown features so that you can't put any other characters than numbers.</p>
  
  <p>Unfortunately now, the jquery.digits() function correctly formats any number to thousands - but yii apparently generates some codes, and then on form validation it says 
  "svalue must be a number".</p>
  
  <p>How can I have both functions, to have a formatted string like the clients wants and to have still a numerical check on the Yii backend?</p>