Answers for "regular expression for numbers and decimal only"

VBA
0

regex for numbers and decimals only

const source = document.getElementById('source');
source.addEventListener('input', allowOnlyNumberAndDecimals);

function allowOnlyNumberAndDecimals(e) {
  let str = e.target.value
  const regExp = /^(d+(.d+)?)$/

  let status = regExp.test(str) ? 'valid' : 'invalid'

  console.log(status + ' : ' + source.value)
}
Posted by: Guest on October-04-2021
0

regex only digits

console.log(`12331: ${/^d+$/.test('12331')}`) // true 
console.log(`abc: ${/^d+$/.test('abc')}`) // false
Posted by: Guest on August-03-2021

Code answers related to "regular expression for numbers and decimal only"

Code answers related to "VBA"

Browse Popular Code Answers by Language