Skip to content

Instantly share code, notes, and snippets.

@zdimaz
Last active July 28, 2021 08:41
Show Gist options
  • Save zdimaz/1b245222c9aa9d2709d3ee5e95d83715 to your computer and use it in GitHub Desktop.
Save zdimaz/1b245222c9aa9d2709d3ee5e95d83715 to your computer and use it in GitHub Desktop.
disabled write words to input
.replace(/[^0-9]/g, '');
exapmle
var val = $(this).prop("value").replace(/[^0-9]/g, '');
/**
** Input Number
**/
inputNumber: function(){
$('.number_input').on("change keyup input click", function() {
if (this.value.match(/[^0-9]/g)) {
this.value = this.value.replace(/[^0-9]/g, '');
}
});
},
$multipleTel.on('input', function () {
$(this).val('+' + $(this).val().toString().replace(/[^0-9]/gi, ''));
});
.replace(/[^0-9]/g, '');
exapmle
var val = $(this).prop("value").replace(/[^0-9]/g, '');
/**
** Input Number
**/
inputNumber: function() {
$('.number_input').on("change keyup input click", function () {
if (this.value.match(/[^0-9]/g)) {
this.value = this.value.replace(/[^0-9]/g, '');
}
});
},
document.querySelectorAll('[type="tel"]').forEach(item => {
item.addEventListener('input', () => {
item.value = item.value.replace(/[^0-9]/g, "");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment