Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. masking the text in textbox c#2003

masking the text in textbox c#2003

Scheduled Pinned Locked Moved C#
tutorialcsharp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vivek g
    wrote on last edited by
    #1

    I want to mask the text for identifying the corrent syntax of IP address example 10.179.10.28 // is correct 10.567.7889.7. // is incorrect how to identify the incorrect one.

    vivek

    M 2 Replies Last reply
    0
    • V vivek g

      I want to mask the text for identifying the corrent syntax of IP address example 10.179.10.28 // is correct 10.567.7889.7. // is incorrect how to identify the incorrect one.

      vivek

      M Offline
      M Offline
      Martin 0
      wrote on last edited by
      #2

      Hello, A quick validation would be to split the string (string.Split('.')) and chek if the elements of the array (return value of Split method is string[]) are not longer than 3 characters. Additionaly you could also check the Length of the string[]. Hope it helps! All the best, Martin

      1 Reply Last reply
      0
      • V vivek g

        I want to mask the text for identifying the corrent syntax of IP address example 10.179.10.28 // is correct 10.567.7889.7. // is incorrect how to identify the incorrect one.

        vivek

        M Offline
        M Offline
        Martin 0
        wrote on last edited by
        #3

        Hello again! Here I found a very nice solution with regex!

        public bool IsValidIPAddress(string ipAddr) {
        string pattern = @"^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$";
        Regex reg = new Regex(pattern, RegexOptions.Singleline | RegexOptions.ExplicitCapture);
        return reg.IsMatch(ipAddr);
        }

        http://blog.devstone.com/Aaron/archive/2006/03/29/222.aspx[^] All the best, Martin

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups