title: On keypress event, how do I change a ',' to a '~'
body: <p>I have to prevent Coldfusion's default list delimiter ',' from being entered into a form input array. I am new to using javascript for validation purposes, and have never tried to switch out the values someone is typing in.  How can I snag a comma, and replace it with a tilda?</p>
  
  <p>Javascript i've tried so far:</p>
  
  <pre><code>    $(document).ready(function(event){
        var regExComma = /,/;
        $("[name='name[]']").live("keypress",function(event){
  // i know i could check the numerical value, i feel this requirement can get more added to it and I would like to just change the regEx accordingly.
          if(regExComma.test(String.fromCharCode(event.which)){
  //it was a ',' switch it to '~'
           event.which = 126;
          }
        });
  // added to show that the 'name' input form array is the only input that cares about the ','
      var regExDig = /[\d]/
      $("[name=min[]],[name=max[]]").live(keypress, function(event){
         if(!regExDig .test(String.fromCharCode(event.which)){
          event.preventDefault();
          $("#cfocFormMessages").trigger("updateMessages", {"url":"components.cfc/CFOC.cfc", "data":{"more":"stuff"}});
         }
      });
              });
  </code></pre>
  
  <p>cfml / html involved:</p>
  
  <pre><code>&lt;form action="components/CatagoryService.cfc?method=saveVersion"&gt;
  &lt;input id="version" name="version" type="text"&gt;
  &lt;!--- .. more inputs ..---&gt;
  &lt;table id="table"&gt;
    &lt;thead&gt;&lt;tr&gt;&lt;th&gt;name col&lt;/th&gt;
    &lt;th&gt;min col&lt;/th&gt;
    &lt;th&gt;max col&lt;/th&gt;
    &lt;th&gt;edit&lt;/th&gt;
  &lt;/tr&gt;&lt;/thead&gt;
    &lt;tfoot&gt;&lt;/tfoot&gt;
    &lt;cfoutput query="variables.query"&gt;
    &lt;tr&gt;&lt;td&gt;&lt;input name="name[]" type="text" value="#variables.query.name#"&gt;&lt;/td&gt;
     &lt;td&gt;&lt;input name="min[]" type="text" value="#variables.query.min#"&gt;&lt;/td&gt;
     &lt;td&gt;&lt;input name="max[]" type="text" value="#variables.query.max#"&gt;&lt;/td&gt;
     &lt;td&gt;&lt;input name="id[]" type="hidden" value="#variables.query.id#"&gt;
       &lt;a href="#" class="editLink"&gt;edit&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/cfoutput&gt;
    &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="#" class="addLink"&gt;add&lt;/a&gt;&lt;/td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  &lt;input type="Submit"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>if I alter CatagoryService.cfc?method=saveVersion to <code>&lt;cfreturn arguments&gt;</code> in a JSON string, a typical response from Coldfusion looks like:</p>
  
  <pre><code>{VERSION:"",name:"name1,name2",min:"1,3", max:"2,4",id:"1,2"}
  </code></pre>