Thursday, March 22, 2012

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

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?Use Regular Expressions.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
What You S Is What You Get.
<CAradhana@.gmail.com> wrote in message
news:1113221781.887525.225470@.l41g2000cwc.googlegroups.com...
>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?
>
Here are some free masked textbox controls you might be able to use:
http://SteveOrr.net/freecontrols/textboxes.aspx
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
<CAradhana@.gmail.com> wrote in message
news:1113221781.887525.225470@.l41g2000cwc.googlegroups.com...
>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?
>
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 . ...
hey steve
Thanx a lot .. I am just checking this site ... thanx again ..
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 S Is What You Get.
<CAradhana@.gmail.com> wrote in message
news:1113283142.390179.181560@.g14g2000cwa.googlegroups.com...
> 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 . ...
>
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.
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: PLBlum@.PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
<CAradhana@.gmail.com> wrote in message
news:1113221781.887525.225470@.l41g2000cwc.googlegroups.com...
>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?
>

0 comments:

Post a Comment