473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Masked input control (or simulation of)?


I'm currently working on what has turned in to something much
larger that I wanted it to be. The upside is that I'm getting $$ to do
it... but anywho.

I currently have textboxes set up to capture phone numbers,
I've also got regular expression validation in place to force the
format of the number to be (xxx) xxx-xxxx. The problem is, the people
that are paying me don't want this. What they'd like to see is a magic
textbox that fills in the ( ) and - as you type, the other alternative
is 3 separate textboxes.. a 2 that are 3 digits wide and one that is
4.

Doing it with the 3 boxes sounds like the 'easier' way to go,
I can simply concatenate the 3 values together as I see fit before
sending them on to the database... however, if I use this method, they
want the focus to automagically move from box to box as the user
enters the digits.

I'm no javascript person, but assume this is what would be
needed to accomplish the result.

So, my question to all of you is... is there a drop-in masked
control that I can use to replace the textbox, or could someone give
me a hint on how to do the hocus focus thing?

Nov 17 '05 #1
7 1912
Hi,

Here's some JavaScript you might use.

I put three textboxes on a form and added this in the HTML:
<script>
function Box1() {
if (Form1.TextBox1.value.length > 2)
Form1.TextBox2.focus();
}
function Box2() {
if (Form1.TextBox2.value.length > 2)
Form1.TextBox3.focus();
}
</script>

You might want to use RegisterClientScriptBlock instead of typing this
directly into the HTML.

Then I added this in the Page_Load
TextBox1.Attributes.Add("onkeypress", "Box1();")
TextBox2.Attributes.Add("onkeypress", "Box2();")

I hope this helps.

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
From: "|{evin" <Yo*@dont.need>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Subject: Masked input control (or simulation of)?
Message-ID: <h4********************************@4ax.com>
X-Newsreader: Forte Agent 1.91/32.564
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 26
NNTP-Posting-Host: 12.223.101.211
X-Complaints-To: ab***@insightbb.com
X-Trace: attbi_s02 1068511243 12.223.101.211 (Tue, 11 Nov 2003 00:40:43 GMT) NNTP-Posting-Date: Tue, 11 Nov 2003 00:40:43 GMT
Organization: Insight Broadband
Date: Tue, 11 Nov 2003 00:40:43 GMT
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!news-out.cwix.com!newsfeed.cwix.co
m!news.umass.edu!arclight.uoregon.edu!wn13feed!wn1 2feed!worldnet.att.net!204
127.198.203!attbi_feed3!attbi_feed4!attbi.com!attb i_s02.POSTED!not-for-mail Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:189898
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
I'm currently working on what has turned in to something much
larger that I wanted it to be. The upside is that I'm getting $$ to do
it... but anywho.

I currently have textboxes set up to capture phone numbers,
I've also got regular expression validation in place to force the
format of the number to be (xxx) xxx-xxxx. The problem is, the people
that are paying me don't want this. What they'd like to see is a magic
textbox that fills in the ( ) and - as you type, the other alternative
is 3 separate textboxes.. a 2 that are 3 digits wide and one that is
4.

Doing it with the 3 boxes sounds like the 'easier' way to go,
I can simply concatenate the 3 values together as I see fit before
sending them on to the database... however, if I use this method, they
want the focus to automagically move from box to box as the user
enters the digits.

I'm no javascript person, but assume this is what would be
needed to accomplish the result.

So, my question to all of you is... is there a drop-in masked
control that I can use to replace the textbox, or could someone give
me a hint on how to do the hocus focus thing?


Nov 17 '05 #2
On Wed, 12 Nov 2003 00:11:21 GMT, mi****@online.microsoft.com ("Mike
Moore [MSFT]") wrote:
Hi,

Here's some JavaScript you might use.

I put three textboxes on a form and added this in the HTML:
<script>
function Box1() {
if (Form1.TextBox1.value.length > 2)
Form1.TextBox2.focus();
}
function Box2() {
if (Form1.TextBox2.value.length > 2)
Form1.TextBox3.focus();
}
</script>

You might want to use RegisterClientScriptBlock instead of typing this
directly into the HTML.

Then I added this in the Page_Load
TextBox1.Attributes.Add("onkeypress", "Box1();")
TextBox2.Attributes.Add("onkeypress", "Box2();")

I hope this helps.

Thank you, Mike
Microsoft, ASP.NET Support Professional


Very similar to something someone else suggested in another group,
altthough this looks a bit cleaner, I am not, however, familiar with
RegisterClientScriptBlock.

Nov 17 '05 #3
Hi,

For more on RegisterClientScriptBlock, please see
Injecting Client-Side Script from an ASP.NET Server Control
http://msdn.microsoft.com/library/en...ectclientsides
c.asp

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
From: "|{evin" <Yo*@dont.need>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Subject: Re: Masked input control (or simulation of)?
Message-ID: <u4********************************@4ax.com>
References: <h4********************************@4ax.com> <Ry**************@cpmsftngxa06.phx.gbl> X-Newsreader: Forte Agent 1.91/32.564
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 35
NNTP-Posting-Host: 12.223.101.211
X-Complaints-To: ab***@insightbb.com
X-Trace: attbi_s02 1068600056 12.223.101.211 (Wed, 12 Nov 2003 01:20:56 GMT) NNTP-Posting-Date: Wed, 12 Nov 2003 01:20:56 GMT
Organization: Insight Broadband
Date: Wed, 12 Nov 2003 01:20:56 GMT
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed 00.sul.t-online.de!t-onlin
e.de!newsfeed.icl.net!newsfeed.fjserv.net!logbridg e.uoregon.edu!arclight.uor
egon.edu!wn13feed!wn12feed!worldnet.att.net!204.12 7.198.203!attbi_feed3!attb
i_feed4!attbi.com!attbi_s02.POSTED!not-for-mail Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:190236
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

On Wed, 12 Nov 2003 00:11:21 GMT, mi****@online.microsoft.com ("Mike
Moore [MSFT]") wrote:
Hi,

Here's some JavaScript you might use.

I put three textboxes on a form and added this in the HTML:
<script>
function Box1() {
if (Form1.TextBox1.value.length > 2)
Form1.TextBox2.focus();
}
function Box2() {
if (Form1.TextBox2.value.length > 2)
Form1.TextBox3.focus();
}
</script>

You might want to use RegisterClientScriptBlock instead of typing this
directly into the HTML.

Then I added this in the Page_Load
TextBox1.Attributes.Add("onkeypress", "Box1();")
TextBox2.Attributes.Add("onkeypress", "Box2();")

I hope this helps.

Thank you, Mike
Microsoft, ASP.NET Support Professional


Very similar to something someone else suggested in another group,
altthough this looks a bit cleaner, I am not, however, familiar with
RegisterClientScriptBlock.


Nov 17 '05 #4
On Wed, 12 Nov 2003 18:42:27 GMT, mi****@online.microsoft.com ("Mike
Moore [MSFT]") wrote:
Hi,

For more on RegisterClientScriptBlock, please see
Injecting Client-Side Script from an ASP.NET Server Control
http://msdn.microsoft.com/library/en...ectclientsides
c.asp

Thank you, Mike
Microsoft, ASP.NET Support Professional


I actually found this sometime after midnight last night. I went on to
develop a custom web control that encapsulated the 3 text boxes, the
movement from field to field, a routine that only allows numbers to be
entered into the textboxes, and a custom validator that forces all 10
digits to be entered.

Best of all, the textbox ID's and all of the javascript are generated
on the fly using RegisterClientScriptBlock.. I can place multiple
instances of the control on a web page and everything still gets
hooked up correctly! (although the page source gets a bit large...
there are 6 javascript functions generated for each control).

Thanks a TON!

Nov 17 '05 #5
On Wed, 12 Nov 2003 00:11:21 GMT, mi****@online.microsoft.com ("Mike
Moore [MSFT]") wrote:
Hi,

Here's some JavaScript you might use.

I put three textboxes on a form and added this in the HTML:
<script>
function Box1() {
if (Form1.TextBox1.value.length > 2)
Form1.TextBox2.focus();
}
function Box2() {
if (Form1.TextBox2.value.length > 2)
Form1.TextBox3.focus();
}
</script>

You might want to use RegisterClientScriptBlock instead of typing this
directly into the HTML.

Then I added this in the Page_Load
TextBox1.Attributes.Add("onkeypress", "Box1();")
TextBox2.Attributes.Add("onkeypress", "Box2();")

I hope this helps.

Thank you, Mike
Microsoft, ASP.NET Support Professional


Well, I thought I had it knocked out. :(

The code that automagically moves the cursor doesn't work with
NetScape 7.

if ( document.all("pcfax_TextBox1").value.length > 2 )
{
document.all("pcfax_TextBox2").focus();
}

I've tried replacing with something like

if ( document.getElementById("pcfax_TextBox1").value.le ngth > 2 )
{
document.getElementByIdl("pcfax_TextBox2").focus() ;
}

But the browser complains that pcfax_TextBox2 has no properties. :(

Is there a cross-browser way to access elements by ID? I've noticed
that a lot of my custom validators do not fire correctly either
because of this same issue.

Nov 18 '05 #6
Hi,

I'm sorry, I don't know the way to do this in Netscape. I recommend that
you try a Netscape oriented newsgroup or chat room. Some can be found at
http://channels.netscape.com/ns/jump...ty/default.jsp

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
From: "|{evin" <Yo*@dont.need>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Subject: Re: Masked input control (or simulation of) - Cross Browser??
Message-ID: <tt********************************@4ax.com>
References: <h4********************************@4ax.com> <Ry**************@cpmsftngxa06.phx.gbl> X-Newsreader: Forte Agent 1.91/32.564
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 54
NNTP-Posting-Host: 12.223.101.211
X-Complaints-To: ab***@insightbb.com
X-Trace: attbi_s53 1069016964 12.223.101.211 (Sun, 16 Nov 2003 21:09:24 GMT) NNTP-Posting-Date: Sun, 16 Nov 2003 21:09:24 GMT
Organization: Insight Broadband
Date: Sun, 16 Nov 2003 21:09:24 GMT
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!news-out.cwix.com!newsfeed.cwix.co
m!news.umass.edu!arclight.uoregon.edu!wn13feed!wor ldnet.att.net!204.127.198.
203!attbi_feed3!attbi_feed4!attbi.com!attbi_s53.PO STED!not-for-mail Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:191228
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

On Wed, 12 Nov 2003 00:11:21 GMT, mi****@online.microsoft.com ("Mike
Moore [MSFT]") wrote:
Hi,

Here's some JavaScript you might use.

I put three textboxes on a form and added this in the HTML:
<script>
function Box1() {
if (Form1.TextBox1.value.length > 2)
Form1.TextBox2.focus();
}
function Box2() {
if (Form1.TextBox2.value.length > 2)
Form1.TextBox3.focus();
}
</script>

You might want to use RegisterClientScriptBlock instead of typing this
directly into the HTML.

Then I added this in the Page_Load
TextBox1.Attributes.Add("onkeypress", "Box1();")
TextBox2.Attributes.Add("onkeypress", "Box2();")

I hope this helps.

Thank you, Mike
Microsoft, ASP.NET Support Professional


Well, I thought I had it knocked out. :(

The code that automagically moves the cursor doesn't work with
NetScape 7.

if ( document.all("pcfax_TextBox1").value.length > 2 )
{
document.all("pcfax_TextBox2").focus();
}

I've tried replacing with something like

if ( document.getElementById("pcfax_TextBox1").value.le ngth > 2 )
{
document.getElementByIdl("pcfax_TextBox2").focus() ;
}

But the browser complains that pcfax_TextBox2 has no properties. :(

Is there a cross-browser way to access elements by ID? I've noticed
that a lot of my custom validators do not fire correctly either
because of this same issue.


Nov 18 '05 #7
On Mon, 17 Nov 2003 19:18:26 GMT, mi****@online.microsoft.com ("Mike
Moore [MSFT]") wrote:
Hi,

I'm sorry, I don't know the way to do this in Netscape. I recommend that
you try a Netscape oriented newsgroup or chat room. Some can be found at
http://channels.netscape.com/ns/jump...ty/default.jsp

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.


Nuts. 95% of this application is used by back-end people. 100% IE. The
other 5% is publicly accessable so I need to get it working at least
there... or redirect them to comebackwitharealbrowser.htm.

:)

Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: metridevkk | last post by:
Hi, I need to use a Masked Edit Control in my ASPX page. In VS.Net, I added the reference to MSMask.dll for my application & also added the MaskEdBox to the Toolbox. After adding the control to...
1
by: david | last post by:
Anybody could give me hint how use this control in asp.net web form. The problem is: I try to use COM component in my web form app by using MS training kit for windows form application. I would...
1
by: Kostis | last post by:
Hello there! I have created a windows application in VB.NET and I want to retrieve data from an access database. I create the OleDbConnection, an OleDbAdapter, a dataset and finally a Data Form...
3
by: Panos | last post by:
Hi all, I can't clear a Masked edit control. I use it to input dates, so I have defined the mask as "##/##/####". I use the the well known meb.mask="" meb.text="" , but nothing happens. Does...
7
by: DazedAndConfused | last post by:
Curently I manualy code keypress edits. i.e. allow only 3 digits before decimal and two digits after decimal in .NET. Is there an easy solution to mask text boxes? The MSMASK32.OCX from vb6...
0
by: jean-michel bain-cornu | last post by:
Hi all, I'm trying to get the whole field selected when the caret arrives into a wx masked control. This is perfectly done with the program below. But if I comment out the line "r=...
3
by: dmbuso | last post by:
I have a money field defined in a SQL Server 05 database with a value of 49.50. Also, it displays in SQL Server as 49.5000. I have a form in VB.NET 2005 and I'm using the new MaskedTextBox control...
2
by: james.czebiniak | last post by:
newbie to .net I have a masked textbox intended to display/input salary. The mask is 999,999 or ###,###. When I place the info from the database into the field it formats incorrectly. The salary...
2
by: gayano | last post by:
Hi, I'm using Visual studio 2005 pro Ver..]]] I have a Form named form1 textbox named txtName masked textbox (Date Masked) named txtMaskedDate and a button to add data named btnAdd dim...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.