I\'m trying to add functionality to input date fields so as when the users enters in digits, slashes \"/\" get automatically added.
So suppose I have the following
If you're looking for pure js version of @Chris's answer
var newInput = document.getElementById("theDate");
newInput.addEventListener('keydown', function( e ){
if(e.which !== 8) {
var numChars = e.target.value.length;
if(numChars === 2 || numChars === 5){
var thisVal = e.target.value;
thisVal += '/';
e.target.value = thisVal;
}
}
});
And HTML section might be(if necessary):