title: Replace multiple instances of a character in a string
body: <pre><code>&lt;form id="form1" method = "post"&gt;
  Text1:&lt;input type ="text" id="textname1"/&gt;&lt;br&gt;
  &lt;input type ="button" name="button2" id="button2" value="UPDATE"&gt;
  &lt;/form&gt;
  
  &lt;script type ="text/javascript"&gt;
      $(document).ready(function() {
          $("#button2").click(function(e){
          alert($("#textname1").attr('value').replace('-',''));
              });
          $( "#textname1" ).datepicker();
          $( "#textname1" ).datepicker("option", "dateFormat", 'yy-mm-dd' );
  
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>Suppose if i enter the date in the field 2010-07-06 .When i  click the button2 i get the alert as 201007-06.How can i replace the last hyphen(-)</p>