Which plugin are you using? I'm guessing that your using Bush's inputmask. You can define your own masks, like you did in the comment but I don't think you can define optional parts (other than defining a mask for each case).
You may want to take a look at RobinHerbots mask (it's based on Bush's mask, so should be trivial to convert).
The nice thing about Robin's masking plugin is that you can define optional characters in a mask (or multiple masks, for that matter)
You should be able to do the following (characters in brackets are optional)
$('txtDateOfBirth').inputmask({ mask: '[9]9/[9]9/9999' });