You are here

Add string after n values

jQuery(function($){

setInterval(function() {
$('.wc-credit-card-form-card-expiry').on('keyup',keyUpHandler);
   
    function keyUpHandler(e){ 
        var element = this;
        var key = e.keyCode || e.which;  
        insertTimingColor(element,key)
    }

    function insertTimingColor(element,key){
        var inputValue = element.value;
        if(element.value.trim().length == 2 && key !== 4){
            element.value = element.value + '/';
        }
    }
}, 100)

});

code type: 
Taken from: 
https://stackoverflow.com/questions/30093786/jquery-how-to-automatically-insert-colon-after-entering-2-numeric-digits