rebirth1078 rebirth1078 - 1 year ago 37
HTML Question

How do I remove space between characters for my text input field

I created an input that will let users created a username.

I to make sure there is no spaces between characters in the input field like:


instead of:

username 1

aje aje
Answer Source

Use split() and join()

$(function() {
  $("input").on("keyup", function() {
    $(this).val($(this).val().split(" ").join(""));
<script src=""></script>
<input type="text"/>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download