Use this:
document.getElementById(target).value = newVal.replace(/[^0-9.]/g, '');
More Related Contents:
- Find list of strings that matches a pattern that start with a special character « and end with a special character »
- Remove text between two parenthesis, if two more parenthesis [closed]
- How to replace plain URLs with links?
- Regular expression to get a string between two strings in Javascript
- Regex to get string between curly braces
- Validate phone number with JavaScript
- Detect URLs in text with JavaScript
- What is the meaning of the ‘g’ flag in regular expressions?
- What is the difference between RegExp’s exec() function and String’s match() function?
- Is there a version of JavaScript’s String.indexOf() that allows for regular expressions?
- Remove HTML Tags in Javascript with Regex
- Remove whitespace and line breaks between HTML elements using jQuery
- Remove HTML comments with Regex, in Javascript
- How to replace last occurrence of characters in a string using javascript
- Validating user’s UTF-8 name in Javascript
- regular expression to match exactly 5 digits
- Regex for number with decimals and thousand separator
- Syntax error in IE using ES6 arrow functions
- Regex to extract substring, returning 2 results for some reason
- Split a string by whitespace, keeping quoted segments, allowing escaped quotes
- How to wrap part of a text in a node with JavaScript
- How to prevent invalid characters from being typed into input fields
- How to convert “camelCase” to “Camel Case”?
- Regex for parsing single key: values out of JSON in Javascript
- What’s the correct regex range for javascript’s regexes to match all the non word characters in any script?
- javascript split string by space, but ignore space in quotes (notice not to split by the colon too)
- Mask US phone number string with JavaScript
- Extract keyword from Google search in Javascript
- Regex matching emoticons
- Regex: only alphanumeric but not if this is pure numeric