I have this code. How I can change it to allow only numbers and at the start.
$(document).on("input", ".numeric>input , .numeric", function() {
this.value = this.value.replace(/[^0-9\.]/g,'');
});
Let me know and many thanks!
CodePudding user response:
You can easily add the as the first digit, as i understand you are trying to match a phone number, your code must be as the following :
$(document).on("input", ".numeric>input , .numeric", function() {
this.value = this.value.replace(/[ 0-9\.]/g,'');
});
here is a beautiful online tool where you can build them easily, you do not have to memorise everything :