You might have to intercept the field on key press event and add the pattern as required after checking the input length.
Ex:
$('#guideContainer-rootPanel-basics-basics1-guidetextbox_15663786___widget').keypress(function(){
// Your code
alert(textbox_156637861551694584667.value);
});
Replace guideContainer-rootPanel-basics-basics1-guidetextbox_15663786___widget with your element ID, you can obtain it from browser debugger. This need to be placed in code editor on initialize event.
Ref: https://api.jquery.com/keypress/
javascript events - jQuery get input value after keypress - Stack Overflow