Textbox control - limiting input

Discussion in 'ASP .Net Web Controls' started by LAL, Jan 15, 2004.

  1. LAL

    LAL Guest

    Greetings...

    I'm pretty new to ASP.NET programming and I have two questions:

    1. How can I automatically change what it typed into a text box to upper
    case as the user is typing on the webpage?

    I tried the following suggestion
    http://www.dotnet247.com/247reference/msgs/33/166114.aspx
    (Basically add a script to call .ToUpperCase on the value of control passed
    in, the call this script in onKeyUp event)
    but onKeyUp doesn't appear to be a recognized event on the TextBox control.

    2. Is there a way to limit what the user types to be numeric characters
    only? In other word, 1234567890 would be the only accepted characters?

    Thanx!
    LAL
     
    LAL, Jan 15, 2004
    #1
    1. Advertising

  2. LAL

    LAL Guest

    Greetings...

    So what you're saying is, "It can't be done." *deep sigh* It sounded like
    such an easy request. Oh well.

    LAL
    "Seb" <> wrote in message
    news:eo1Ob.11479$...
    > This cannot be done on a webpage regardless of ASP.NET. The client side of

    a
    > web page is automated by javascript. The onChange event will fire in
    > Javascript as the user selects, clicks, or tabs to a control other than

    your
    > textbox. This is when the event will fire and when you can change the

    case
    > of your textbox.
    >
    > "LAL" <> wrote in message
    > news:#...
    > > Greetings...
    > >
    > > I'm pretty new to ASP.NET programming and I have two questions:
    > >
    > > 1. How can I automatically change what it typed into a text box to upper
    > > case as the user is typing on the webpage?
    > >
    > > I tried the following suggestion
    > > http://www.dotnet247.com/247reference/msgs/33/166114.aspx
    > > (Basically add a script to call .ToUpperCase on the value of control

    > passed
    > > in, the call this script in onKeyUp event)
    > > but onKeyUp doesn't appear to be a recognized event on the TextBox

    > control.
    > >
    > > 2. Is there a way to limit what the user types to be numeric characters
    > > only? In other word, 1234567890 would be the only accepted characters?
    > >
    > > Thanx!
    > > LAL
    > >
    > >

    >
    >
     
    LAL, Jan 19, 2004
    #2
    1. Advertising

  3. LAL

    Dan Forster Guest

    For Q 2:

    You can use the following javascript:

    function nb_numeralsOnly(evt)

    {

    evt = (evt) ? evt : event;

    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode
    : ((evt.which) ? evt.which : 0));

    if (charCode > 31 && (charCode < 48 || charCode >57)) {return false;}

    return true;

    }

    and bind :

    onkeypress='return nb_numeralsOnly(event);'

    for Question 1 you could use:

    function setUpper(evt)
    {

    evt = (evt) ? evt : event;
    var kc = evt.keyCode;
    if (kc>96 && kc<123)
    {
    evt.keyCode=kc-32;
    }
    return true;
    }

    This will still allow other characters but translates lower case
    non-accented latin characters to upper case while typing.

    bind in the same way as above.

    onkeypress='return setUpper(event);'

    Dan

    "LAL" <> wrote in message
    news:...
    > Greetings...
    >
    > So what you're saying is, "It can't be done." *deep sigh* It sounded

    like
    > such an easy request. Oh well.
    >
    > LAL
    > "Seb" <> wrote in message
    > news:eo1Ob.11479$...
    > > This cannot be done on a webpage regardless of ASP.NET. The client side

    of
    > a
    > > web page is automated by javascript. The onChange event will fire in
    > > Javascript as the user selects, clicks, or tabs to a control other than

    > your
    > > textbox. This is when the event will fire and when you can change the

    > case
    > > of your textbox.
    > >
    > > "LAL" <> wrote in message
    > > news:#...
    > > > Greetings...
    > > >
    > > > I'm pretty new to ASP.NET programming and I have two questions:
    > > >
    > > > 1. How can I automatically change what it typed into a text box to

    upper
    > > > case as the user is typing on the webpage?
    > > >
    > > > I tried the following suggestion
    > > > http://www.dotnet247.com/247reference/msgs/33/166114.aspx
    > > > (Basically add a script to call .ToUpperCase on the value of control

    > > passed
    > > > in, the call this script in onKeyUp event)
    > > > but onKeyUp doesn't appear to be a recognized event on the TextBox

    > > control.
    > > >
    > > > 2. Is there a way to limit what the user types to be numeric

    characters
    > > > only? In other word, 1234567890 would be the only accepted

    characters?
    > > >
    > > > Thanx!
    > > > LAL
    > > >
    > > >

    > >
    > >

    >
    >
     
    Dan Forster, Jan 21, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. S. Justin Gengo
    Replies:
    0
    Views:
    553
    S. Justin Gengo
    Jul 16, 2003
  2. Neven Klofutar

    Limiting Multiline textbox

    Neven Klofutar, Nov 22, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    5,294
    Page Brooks
    Nov 22, 2004
  3. =?ISO-8859-1?Q?Otto_Kr=FCse?=

    limiting text input in Tkinter Entry widget

    =?ISO-8859-1?Q?Otto_Kr=FCse?=, Feb 22, 2004, in forum: Python
    Replies:
    5
    Views:
    3,298
    Peter Otten
    Feb 23, 2004
  4. A
    Replies:
    14
    Views:
    534
    Arne Mertz
    Oct 26, 2011
  5. Paul
    Replies:
    3
    Views:
    145
    dotnettester
    Jul 7, 2005
Loading...

Share This Page