IP Address Input - Advanced Installer Community
jtellier
Posts: 6
Joined: Tue Jun 30, 2020 1:41 am

IP Address Input

Anyone have a working example of how to force an input control to only accept an IP Address?

I tried things like <###.###.###.###> and <#.#.#.#> on a Masked Edit but those aren't right, I tried making Custom Actions to validate input but I don't even see those firing.

Any samples would be much appreciated, thanks!
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: IP Address Input

Hello,

For this, you should do something similar to the following article written by my colleague Liviu:

Validate user input and display specific icon/error message

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Catalin
Posts: 7852
Joined: Wed Jun 13, 2018 7:49 am

Re: IP Address Input

As a followup to my last thread, here would be a sample PowerShell that validates an IP address:

Code: Select all

# Prompt the user for an IP address
$ip = Read-Host "Please enter an IP address"
# Define a regular expression for matching IP addresses
$regex = "\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
# Use the regular expression to validate the IP address
if ($ip -match $regex) {
  Write-Host "The IP address is valid"
} else {
  Write-Host "The IP address is not valid"
}
You should adjust this with the help of the article to match your needs.

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”