0

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

2
  • 1
    You should show the code you've already tried. Commented Jan 17, 2014 at 12:29
  • Sorry :/ im new to this. Commented Jan 17, 2014 at 12:38

3 Answers 3

3

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);"
Sign up to request clarification or add additional context in comments.

Comments

1

you can use this function to remove spaces, try it:

function removeSpaces(ch)
{
   ch = ch.replace(/\ /g,"");
   return ch;
 }

Comments

0

You can use via jquery trim function.

http://api.jquery.com/jquery.trim/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.