Reputation: 55
Is there a way to remove any spaces in a form field, the "onblur" solutions when i have googled it are not working for me. Is it anything to do with browser compatability? Im using IE10
Upvotes: 0
Views: 2205
Reputation: 64
you can use this function to remove spaces, try it:
function removeSpaces(ch)
{
ch = ch.replace(/\ /g,"");
return ch;
}
Upvotes: 1
Reputation: 265
You can use via jquery
trim function.
http://api.jquery.com/jquery.trim/
Upvotes: 0
Reputation: 385
Put this between your head tags:
<script language="javascript" type="text/javascript">
function removeSpaces(string) {
return string.split(' ').join('');
}
</script>
And this in your input tag:
onblur="this.value=removeSpaces(this.value);"
Upvotes: 3