you need to sub class the CEdit class and have your own event handler for the keypress / keydown event and then handle the characters accordingly. Also if you wish you can validate in the lost focus event there.