Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

input field take only number and one comma

function checkKey() {
    var clean = this.value.replace(/[^0-9,]/g, "")
                           .replace(/(,.*?),(.*,)?/, "$1");
    // don't move cursor to end if no change
    if (clean !== this.value) this.value = clean;
}

// demo
document.querySelector('input').oninput = checkKey;
Comment

PREVIOUS NEXT
Code Example
Javascript :: Jquery handle change event of file upload created dynamically 
Javascript :: javascript onsubmit 
Javascript :: docker react 
Javascript :: Javascript how to compare three numbers 
Javascript :: json decode list flutter 
Javascript :: fill an array of zeroes in js 
Javascript :: nodejs mysql insert query 
Javascript :: how to change text in html using javascript 
Javascript :: find space in string js 
Javascript :: javascript .fill 
Javascript :: how to detect a url change 
Javascript :: javascript hashtag url 
Javascript :: get full month from date javascript 
Javascript :: array of objects to array 
Javascript :: jquery add multiple classes 
Javascript :: create array with number js 
Javascript :: javascript format date object to yyyy-mm-dd 
Javascript :: javascript operator double pipes 
Javascript :: Use the parseInt Function with a Radix 
Javascript :: webpack react proxy not working 
Javascript :: Remove duplication from array in javascript 
Javascript :: javascript getminutes 2 digits 
Javascript :: Deep copy objects js JSON methods 
Javascript :: custom event handler javascript 
Javascript :: how to reload window in javascript 
Javascript :: js conditional object key 
Javascript :: delete a property of html by js 
Javascript :: npm stylelint 
Javascript :: Set timeouts to XMLHttpRequests in javascript 
Javascript :: how to create a server in node js 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =