ID Number Validation
-
We want to design an application which requires the user to input his/her ID number for validation.
-
When the application starts, it shows a message in the edit box to prompt the user typing an ID number.
At this moment, the button is disabled.
- If the input string
length is not 10 characters, the button should not be enabled.
- If the first character is not an English alphabet, or the other nine characters are not digits, the string is certainly not a valid ID number.
- The second character should be either 1 or 2. Otherwise, it is invalid.
- For the abovementioned invalid input, the button should not be
enabled.
- When the button was clicked, it automatically converts the input
string to uppercase
by the MakeUpper() member function of CString,
and apply
this
rule to validate the ID number.
-
If it is valid, change the static text control to show "Correct".
-
If it is invalid, change the static text control to show "Incorrect!" in
red color.