client side validation with asp:TextBox ???

Discussion in 'ASP .Net' started by Christian Cambier, Jul 14, 2008.

  1. Hello,

    I have a textbox in which I only want to display numbers when the
    focus is set on the textbox and the user presses a key on the kb.
    Easy with html-control <input id="htmlTxtVal2" type="text"
    onkeypress="return NoNumbers(event)" and javascript (implement the
    onkeypres event handler)

    But how to implement it when using the asp:TextBox control ?
    Seems to me that a validation control doesn't work 'cause validation
    is only performed when the user clicks the send-button, and NOT when
    the user is still entering the information in the textbox.

    So, how?

    thank you
    Chris
    Christian Cambier, Jul 14, 2008
    #1
    1. Advertising

  2. On Jul 14, 5:58 pm, "Mark Rae [MVP]" <> wrote:
    > "Christian Cambier" <> wrote in message
    >
    > news:...
    >
    > > I have a textbox in which I only want to display numbers when the
    > > focus is set on the textbox and the user presses a key on the kb.
    > > Easy with html-control <input id="htmlTxtVal2" type="text"
    > > onkeypress="return NoNumbers(event)" and javascript (implement the
    > > onkeypres event handler)

    >
    > > But how to implement it when using the asp:TextBox control ?

    >
    > MyTextBox.Attributes.Add("onkeypress", "return NoNumbers(event);");
    >
    > --
    > Mark Rae
    > ASP.NET MVPhttp://www.markrae.net


    thank you for the great tip!

    Chris
    Christian Cambier, Jul 14, 2008
    #2
    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. Matthew Wieder
    Replies:
    2
    Views:
    3,727
    Matthew Wieder
    Jul 23, 2003
  2. Matt
    Replies:
    14
    Views:
    4,093
    Chad Z. Hower aka Kudzu
    Jan 30, 2004
  3. =?Utf-8?B?dmlkeWE=?=
    Replies:
    1
    Views:
    748
    Kevin Spencer
    Jun 2, 2005
  4. Boss302
    Replies:
    0
    Views:
    1,035
    Boss302
    Nov 21, 2006
  5. Bogdan
    Replies:
    2
    Views:
    644
    Bogdan
    Jun 9, 2008
Loading...

Share This Page