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
Post a Comment