Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Plz help me how to validate a masked textbox for an ip address like this ###.###.###.###? how can i enter 194.5.6.222? without having to enter it as 184.005.006.222?
Posted 31-Jan-13 9:02am
Comments
JemiM at 31-Jan-13 14:07pm
   
please put a nice heading for the question.
Sergey Alexandrovich Kryukov at 31-Jan-13 14:09pm
   
Also, Tag your UI library or application type. And, no matter how you do it, you always need to enter or select those integers, isn't that obvious?
Tag the UI you use; and you will get help almost immediately.
—SA
Dave Kreskowiak at 31-Jan-13 20:59pm
   
You neeeeeeeed to GROW UP and stop using childish language and txtspeak. You've got full keyboard in front of you. Use it! If you want people to take you seriously, you'll do this.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I wouldn't use a masked edit box for this - they are really only usefull for fixed input format, not flexible ones as you need.
Instead, I would use a standard TextBox and a regex to validate it:
^(?<first>2[0-4]\d|25[0-5]|[01]?\d\d?)\.(?<second>2[0-4]\d|25[0-5]|[01]?\d\d?)\.(?<third>2[0-4]\d|25[0-5]|[01]?\d\d?)\.(?<fourth>2[0-4]\d|25[0-5]|[01]?\d\d?)$</fourth></third></second></first>
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 31-Jan-13 14:10pm
   
It's only OP thinks that validation is needed, but really it's about a masked text box or other input method...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 OriginalGriff 120
3 PIEBALDconsult 110
4 BillWoodruff 85
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 31 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100