regex jquery remove all double spaces

Posted by michael on Stack Overflow See other posts from Stack Overflow or by michael
Published on 2010-04-27T15:41:07Z Indexed on 2010/04/27 15:43 UTC
Read the original article Hit count: 269

Filed under:
|

Hi I have this code, I want it to remove all the double spaces from a text area, but it will only remove the first occurrence each time.

$(document).ready(function(){
  $("#article").blur(function(){
    ///alert($(this).val());
    $(this).val($(this).val().replace(/\s\s+/, ' '));
  });
});

I've also tried removeAll(), but it won't work at all. any help would be great, thanks. I have a live example online at http://jsbin.com/ogasu/2/edit

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about regex