Mask Edit control In ASP.NET for phone # or Zip

C

CAradhana

I have a textbox whose text should be of the format "xxx-xxx-xxxx"
i.e if the user enters 1234567890 it should automatically show as
123-456-7890. How do i achieve this in ASP.NET with validations?
 
K

Kevin Spencer

Use Regular Expressions.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
C

CAradhana

Hi kevin :)

u are rite, regular exp is working fine to check the input format ...
but i want smthing like IP address text box in windows or Registration
key textbox. while entering value itself it should include "-"
automatically or else i have to use separate text boxes for each number
groups...

suppose i am using 3 text boxes for "xxx" - "xxx" - "xxxx"

then I have to use 3 validation controls for them ...
and finally have to write code for combine validation . ...
 
K

Kevin Spencer

I'm sorry, but I'm having trouble understanding the problem as you've stated
it here. You say you want something "like IP address text box" but
apparently it is NOT an IP address, as an IP address is 4 numbers separated
by periods. In any case, if you want, for example, 3 boxes with numbers in
them that will be concatenated together somehow, your only requirement is to
check each box for a number. If your requirement is more specific, you can
set a range of valid numbers. And as for combining them, well, the sum of
the parts will make up the whole. If all 3 boxes validate, then you don't
have to check again to make sure that the combination is valid.

I must be missing something.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
A

Adrian Parker

There isn't a specific edit mask input field in dotnet, you'll have to write
your own capturing each keypress and moving around the defaulted fixed
chars.
 
P

Peter Blum

As of Sunday, I have released my newest version of Professional Validation
And More. It includes a new control that solves this problem:
MultiSegmentDataEntry.
It handles the same type of data as a masked textbox using separate
textboxes with keystroke filtering and autotabbing.
Demo: http://www.peterblum.com/VAM/DemoMultiSeg.aspx
Product details: http://www.peterblum.com/vam/home.aspx
You can also buy it separately from Professional Validation And More in a
product I call VAM: Data Entry Controls.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top