Why String.replace() doesn't work with events??
var el = document.querySelector('input')
var pat = /(\d{3})(\d{3})(\d{4})/;
el.oninput = function(){
this.value.replace(pat, '$1-$2-$3')
}
Why String.replace() doesn't work with events??
var el = document.querySelector('input')
var pat = /(\d{3})(\d{3})(\d{4})/;
el.oninput = function(){
this.value.replace(pat, '$1-$2-$3')
}
Okay you aren't assigning it, or returning back, as you need to set the new value:
var el = document.querySelector('input')
var pat = /(\d{3})(\d{3})(\d{4})/;
el.oninput = function(){
this.value = this.value.replace(pat, '$1-$2-$3')
}