When the date of birth is entered in my input, I want a full stop after 2 characters are entered automatically. I know it's done with toLocaleLowerCase
Sample: 01011980
Output: 01.01.1980
CodePudding user response:
If the sample is always fixed length which I guess it is, you can do it like this:
var sample = '01011980';
function processString(inputString){
return inputString.substr(0,2) '.' inputString.substr(2,2) '.' inputString.substr(4,4);
}
output = processString(sample);
alert(output);