davidgagne.net

  • About
  • Archives
  • Twitter
  • Facebook
  • bartender.live
  • GitHub
  • LinkedIn

Strip Non-Numeric Characters in JavaScript

June 5th, 2012 @ 11:54 pm PDT

This function is handy when validating input

Strip Non-Numeric Characters in JavaScript

If you need to strip all non-numeric characters from a string (except for the period character) using JavaScript, try:

string.replace(/[^\d.]/g, "");

More posts tagged:
code / javascript / Programming

More posts categorized:
asides Programming

More posts from:
June 2012 / 2012

Post navigation

Previous Post
Previous Post Ernest Hemingway’s Standing Desk
Next Post
Next Post Tickle Me.gov

Search


Awesome Web Hosting

Awesome Web Hosting

I've trusted DreamHost to power this website – and nearly 100 other ones – since March 22, 2001. They have great prices, excellent customer support, and a killer web interface to manage your domains.

  • Get Your Own Website

© David Vincent Gagne. All rights reserved. Custom WordPress Theme by Jacket Industries.