I have two input fields which need to be formatted a certain way. Ipv4 addresses need to have the "." to separate the numbers and ipv6 addresses need to have ":". I'm not sure what the best text should be in order to ensure the user enters their data correctly. Should I show them an example of the format (like the image below)? I wanted to use something like mm/dd/yyyy, but there is no equivalent for IP addresses.

enter image description here

1 Answer 1


There isn't a straightforward solution to this. Using masking is an option, but determining the number of digits in the IP is a challenge.

I would suggest adopting a post-interaction strategy: start by validating if the user is including dots in IPv4 and colons in IPv6. This initial step will assist in conducting a basic check to ensure that the format is correct. Although it doesn't confirm the validity of the address, it helps in maintaining the proper format.

Realistically, in most instances, users are unlikely to input information manually. They would rather copy and paste, which implies that your main task might be to sanitize blank spaces at most. Thus, I believe any possible issues will come with user testing, right now you can't do much than what you already did and the additional steps I mention. If it works or not is something you'll find out at a later time

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.