This may sound like it has nothing to do with your post, but it does. Check out the Mail (or SMTP Mail) codeunit, can’t remember which one. There is a function that verifies email addresses. Basically it looks for an @ sign and a period.
You’ll want a for loop to loop through each character of the string. Then you’ll need to examine each character to make sure it is what you expect it to be. You may want to be careful, because technically 1M + 2M should also be a valid entry.
Of course if you want to go the super lazy way…IF (Input <> ‘1M’) AND (Input <> ‘2M’) …AND (Input <> ‘12M’) THEN…but even then, I think 13M should still be valid.