logo
Search
showing results for - "input field take only number and one comma"
Lucas
19 Feb 2016
1function checkKey() {
2    var clean = this.value.replace(/[^0-9,]/g, "")
3                           .replace(/(,.*?),(.*,)?/, "$1");
4    // don't move cursor to end if no change
5    if (clean !== this.value) this.value = clean;
6}
7
8// demo
9document.querySelector('input').oninput = checkKey;
source
similar questions
type numeric value only in textbox javascriptinput text tag only input integer numberreact allow only numbers in inputallow only numerics and few alphabets in input type jsonly numeric values are allow in input jquery
queries leading to this page
how to show number in input field with commajquery textbox type only number and semicoloninput field only allow numbers and commataking number without comma from input formhtml allow only numbers and comma in inputinput field take only number and one commahtml input only numbers and commahtml input text number only with comma separatorinput number type commahtml input number format commaallow comma in number inputallow only numbers and comma in textboxinput field take only number and one commajavascript number input onlly commainput text number format with commaonly allow numbers and commas in inputinput field accept only numbers and commainput field take only number and one comma
privacy policyterms of useinstagram
Crafted with  ♥  for everyone

sign in to continue
your answer for
you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content
please ensure to add code which is syntactically corrent and executes properly
sign in to continue
ask question on maxinterview
you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content
please be clear, to the point and respectful
sign in to continue