As regex could be not the optimal solution for validating the IP addresses, as my need would be to validate for both IPv4 and IPv6. Is there a solution that already addresses the support of input of IPv4 as well as IPv6.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The normal TextBox supports the input of both IPv4 addresses and IPv6 addresses as well as any other text. If you’re looking for a control that accepts only IPv4 addresses and IPv6 addresses — don’t do this.
IP addresses (and in particular IPv6 addresses) are seldom entered from scratch. Most of the time they are copied from somewhere else and are not necessarily in the right format. If the address is not in the right format, the user often cannot change it in the place where it’s copied from — the user needs to be able to paste it into the TextBox and edit it there. This is not possible if the TextBox does not accept invalid input.
Solution: use a normal TextBox and validate the input when the user clicks the Submit/Next/OK button.