javascript - How can I allow the user to input Numeric (with/without decimal point) only. OR numeric with 'K'/'B' -


i've been searching through stack overflow, can't right answer question.

how can allow user input number or number 'k (thousands)' or 'm (millions)'?

i've tried using patterns, regexp, etc.

is there regular expression this? tried using ^[0-9]*$ , ^[0-9\k\m]*$, don't know if correct expression.

think mean this,

document.write(/^\d+(?:\.\d+)?[km]?$/.test('121k') + '<br/>');  document.write(/^\d+(?:\.\d+)?[km]?$/.test('121.7m') + '<br/>');  document.write(/^\d+(?:\.\d+)?[km]?$/.test('121.45') + '<br/>');


Comments

Popular posts from this blog

javascript - Hide toolbar of pdf file opened inside iframe using firefox -

Ansible - ERROR! the field 'hosts' is required but was not set -

Copy range with conditional formatting -