You are testing for a strange collection of ASCII values. Your allowed values are:
8 [backspace]
46 .
35 #
36 $
37 %
38 &
39 '
40 (
48-57 digits 0-9
96 `
97-105 letters a-i
You may want to visit
http://www.asciitable.com/[
^] to see what you really want.
I'm not sure why you can't type a period, but that seems to be only one of many problems with the code.