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

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

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -