Remove Spaces From a Text Field Using JavaScript

If you want to remove spaces from a String / Text box, Use the following code :

<script language="javascript" type="text/javascript">
  function removeSpaces(inputString) {
    return inputString.split(' ').join('');
}
</script>

One thought on “Remove Spaces From a Text Field Using JavaScript

  1. Please add a null check..:)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>