var value = idInput.value; if (/^\.|\d+\..*\.|[^\d\.{1}]/.test(value)){ idInput.value = value.slice(0,-1); }