showing results for - "regex for numbers and decimals only"
Nils
10 Nov 2020
1const source = document.getElementById('source');
2source.addEventListener('input', allowOnlyNumberAndDecimals);
3
4function allowOnlyNumberAndDecimals(e) {
5  let str = e.target.value
6  const regExp = /^(\d+(\.\d+)?)$/
7
8  let status = regExp.test(str) ? 'valid' : 'invalid'
9
10  console.log(status + ' : ' + source.value)
11}
queries leading to this page
regex number 3 digits decimalregex for amount accepts decimalsregex find decimal numbers in stringregex number to integer no decimalregex copy only numbers and decimalsregex to accept from 0 to 2 decimalsregex check for numbers including decimalsregex number with decimalregex check for decimalregex for write decimal numbers onlyregex to match decimal numbersregex for numbers and decimalsonly decimal number regexregex to accept only numbers and decimalsregex match digits with decimalregex code for decimals and negative numberonly positive numbers and decimal regexpicking numbers with decimals by using regexregex for decimal or integerregex 0 to 4 digitsregex numbers and decimals onlyregex for numbers and decimals only inputregex search for numbers starting with decimalsregex validation for 1 0 as decimalregex match decimal or integerregex match numbers with decimalsregex allow number and decimalregex for decimal or numberamount should take decimal value regexregex to accept only numbers including decimals javaregex to accept only numbers and 3 decimalsonly positive numbers and decimal regex replaceonly numbers and decimal regexfind only decimal using regular expressionregex for a decimal numberregex for decimal number onlyregex only allow numbers and decimalregex for integere or decimal numberregex for one or more digit number decimalregex to accept 3 decimal numbersregex to check for decimal numbers10 number and 2 decimal places regexregex integer with fixed digitsregex for numbers and decimals onlyregex for decimalregex match number with decimalregex for decimal numberregex selecting decimal numbersregex for decimal numberonlyregex numbers with decimalregular expression for numbers and decimal onlyregex for numbers and decimals only