Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
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
Comments
Jameel VM 31-Jan-13 14:07pm    
please put a nice heading for the question.
Sergey Alexandrovich Kryukov 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 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

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>
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900