I want to now how validate a Phone number where accept12 Characters only.When the user clicks a button, the program should determine if the entry is of the form 999-999-9999, where the character 9 represents any number.
If the entry is determined to be a telephone number, display an appropriate message, along with the separate substrings that compose the telephone number without the dashes. If the entry is not a telephone number, then display a message as to the reason why the entry is not a valid telephone number, clear the TextBox control and set focus to the TextBox control. Use String class methods to solve the problem.
A. Check that the user has entered two dashes in the appropriate spaces.
B. Break the string into 3 substrings, represented as 999,999, and 9999.
Logic
particular think
thaks Z
If the entry is determined to be a telephone number, display an appropriate message, along with the separate substrings that compose the telephone number without the dashes. If the entry is not a telephone number, then display a message as to the reason why the entry is not a valid telephone number, clear the TextBox control and set focus to the TextBox control. Use String class methods to solve the problem.
A. Check that the user has entered two dashes in the appropriate spaces.
B. Break the string into 3 substrings, represented as 999,999, and 9999.
Logic
- <LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level2 lfo2; tab-stops: list 1.0in">I want to user feedback on the correctness of the input. Some are more user friendly than others. However, it may require a lot of coding to account for various situations. <LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level2 lfo2; tab-stops: list 1.0in">The simple way is the following:
- <LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level3 lfo2; tab-stops: list 1.5in">First I want to check the length of the input string: it must be exactly 12. <LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level3 lfo2; tab-stops: list 1.5in">Then check for Substring(3, 1) and Substring(7, 1),i.e. the fourth and eighth character must be “-“ <LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level3 lfo2; tab-stops: list 1.5in">I want to use the Substring method to separate the input string into 3 parts <LI class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level3 lfo2; tab-stops: list 1.5in">I want to see if each part is only numeric characters, using IsNumeric and IndexOf.
- If error, display error message box.
- I want to use a loop if is possible,but I have to use the if-then-else statement
particular think
thaks Z