REGEX Remove Commas From Form Textfield

Just in case you ever wanted to remove commas from a form automatically, this is one way to do it. It uses the javascript “onblur” trick. So when ever the mouse leaves this field, it calls the piece of code.

Why would you ever want to remove commas from a form?
MySQL databases don’t always like commas. When sorting, it can get a little hairy trying to tell which value is greatever… 1,000 or 1000. When in doubt, I just remove the commas altogether. There is probably some better method from a guy with a php in nerdness, but this is does the trick for me.

In this case the code is this:
onblur=”this.value=this.value.replace(/,/g,”)”

In action, it looks like this:

Brandon

One Response to “REGEX Remove Commas From Form Textfield”

  1. Cape Girardeau Website / Recording Guy » Blog Archive » REGEx Price Explained Says:

    […] Cape Girardeau Website / Recording Guy « REGEX Remove Commas From Form Textfield […]

Leave a Reply

You must be logged in to post a comment.