Thursday, March 22, 2012

Mask for text boxes

Hi
I am using text boxes on a web form. How can I make it so users can insert
values only in the format 99-99-99 ?
Thanks
RegardsTry using the RegularExpressionValidator, which will validate the user's
input. If you want to restrict the characters that the user can type, you
can use JavaScript (there is a function I wrote that adds this JavaScript if
you would like me to send it to you). You can also use something from the
ASP.NET AJAX Control Toolkit called MaskedEdit, which you can see a
demonstration of at:
http://ajax.asp.net/ajaxtoolkit/Mas...MaskedEdit.aspx
However, if you do not have the ASP.NET AJAX Control Toolkit already
installed, that may be more work than it's worth (my function is much
simpler, and you do not need to install anything or change any configuration
settings, but is not as fancy). Hopefully one of these options is what you
are looking for, or at least helps you find a solution. Good Luck!
--
Nathan Sokalski
njsokalski@.hotmail.com
http://www.nathansokalski.com/
"John" <John@.nospam.infovis.co.uk> wrote in message
news:O%23j21h9UHHA.4784@.TK2MSFTNGP03.phx.gbl...
> Hi
> I am using text boxes on a web form. How can I make it so users can insert
> values only in the format 99-99-99 ?
> Thanks
> Regards
>
>
Checked out that Masked Edit Control, looks good, but WHY part of the AJAX
toolkit.
Is it doing ANYTHING that is asynchronous? Surely this can be implemented
completely client side with Javascript.
I suppose this control collection is MUCH more up to date and where all the
work is happening.
Just seems a bit weird...
"Nathan Sokalski" <njsokalski@.hotmail.com> wrote in message
news:eNXz$A%23UHHA.4568@.TK2MSFTNGP02.phx.gbl...
> Try using the RegularExpressionValidator, which will validate the user's
> input. If you want to restrict the characters that the user can type, you
> can use JavaScript (there is a function I wrote that adds this JavaScript
> if you would like me to send it to you). You can also use something from
> the ASP.NET AJAX Control Toolkit called MaskedEdit, which you can see a
> demonstration of at:
> http://ajax.asp.net/ajaxtoolkit/Mas...MaskedEdit.aspx
> However, if you do not have the ASP.NET AJAX Control Toolkit already
> installed, that may be more work than it's worth (my function is much
> simpler, and you do not need to install anything or change any
> configuration settings, but is not as fancy). Hopefully one of these
> options is what you are looking for, or at least helps you find a
> solution. Good Luck!
> --
> Nathan Sokalski
> njsokalski@.hotmail.com
> http://www.nathansokalski.com/
> "John" <John@.nospam.infovis.co.uk> wrote in message
> news:O%23j21h9UHHA.4784@.TK2MSFTNGP03.phx.gbl...
>
Well, since I didn't write the controls I can't answer that for sure, but
there is a way to download the source code that was used to write them (it
is C# code). I am guessing, however, that the AJAX part is because of the
watermark (like the TextBoxWatermark control located at
http://ajax.asp.net/ajaxtoolkit/Tex...xWatermark.aspx). Or
it might just be to simplify the coding, I haven't looked at the source
code. But I agree with you, it probably is possible to get the same (or at
least close to) the same results without using AJAX.
--
Nathan Sokalski
njsokalski@.hotmail.com
http://www.nathansokalski.com/
"Rich" <r@.r.r> wrote in message
news:45d940ee$0$1146$61c65585@.un-2park-reader-01.sydney.pipenetworks.com.au...d">
> Checked out that Masked Edit Control, looks good, but WHY part of the AJAX
> toolkit.
> Is it doing ANYTHING that is asynchronous? Surely this can be implemented
> completely client side with Javascript.
> I suppose this control collection is MUCH more up to date and where all
> the work is happening.
> Just seems a bit weird...
>
> "Nathan Sokalski" <njsokalski@.hotmail.com> wrote in message
> news:eNXz$A%23UHHA.4568@.TK2MSFTNGP02.phx.gbl...
>
I am trying to use RegularExpressionValidator as it seems to be easiest to
me. What expression do I need for the following type of values;
A9 9AA
A99 9AA
A9A 9AA
AA9 9AA
AA99 9AA
AA9A 9AA
and
99-99-99
A= Alphabets (A-Z, a-z)
9 = digits (0-9)
Many Thanks
Regards
"Nathan Sokalski" <njsokalski@.hotmail.com> wrote in message
news:eNXz$A%23UHHA.4568@.TK2MSFTNGP02.phx.gbl...
> Try using the RegularExpressionValidator, which will validate the user's
> input. If you want to restrict the characters that the user can type, you
> can use JavaScript (there is a function I wrote that adds this JavaScript
> if you would like me to send it to you). You can also use something from
> the ASP.NET AJAX Control Toolkit called MaskedEdit, which you can see a
> demonstration of at:
> http://ajax.asp.net/ajaxtoolkit/Mas...MaskedEdit.aspx
> However, if you do not have the ASP.NET AJAX Control Toolkit already
> installed, that may be more work than it's worth (my function is much
> simpler, and you do not need to install anything or change any
> configuration settings, but is not as fancy). Hopefully one of these
> options is what you are looking for, or at least helps you find a
> solution. Good Luck!
> --
> Nathan Sokalski
> njsokalski@.hotmail.com
> http://www.nathansokalski.com/
> "John" <John@.nospam.infovis.co.uk> wrote in message
> news:O%23j21h9UHHA.4784@.TK2MSFTNGP03.phx.gbl...
>
Try taking a look at the following .NET documentation page:
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_fxfund/html/0f8b
ffab-ee0d-4e0e-9a96-2b4a252bb7e4.htm
You probably want the following expression:
"\d\d-\d\d-\d\d"
However, take note that in this expression there MUST be a digit for \d. If
you want to make a \d optional, add a ? after it, as in the following:
"\d?\d-\d?\d-\d?\d" (this expression would match 1-1-1 or 12-12-12)
For more information on the ? see the following documentation page:
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_fxfund/html/36b8
1212-6511-49ed-a8f1-ff080415312f.htm
Hopefully this will help you get started. Good Luck!
--
Nathan Sokalski
njsokalski@.hotmail.com
http://www.nathansokalski.com/
"John" <John@.nospam.infovis.co.uk> wrote in message
news:OVyX5BEVHHA.4796@.TK2MSFTNGP05.phx.gbl...
>I am trying to use RegularExpressionValidator as it seems to be easiest to
>me. What expression do I need for the following type of values;
> A9 9AA
> A99 9AA
> A9A 9AA
> AA9 9AA
> AA99 9AA
> AA9A 9AA
> and
> 99-99-99
> A= Alphabets (A-Z, a-z)
> 9 = digits (0-9)
> Many Thanks
> Regards
> "Nathan Sokalski" <njsokalski@.hotmail.com> wrote in message
> news:eNXz$A%23UHHA.4568@.TK2MSFTNGP02.phx.gbl...
>

0 comments:

Post a Comment