client side validation with asp:TextBox ???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christian Cambier

    client side validation with asp:TextBox ???

    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="ret urn 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
  • Mark Rae [MVP]

    #2
    Re: client side validation with asp:TextBox ???

    "Christian Cambier" <christian.camb ier@gmail.comwr ote in message
    news:9f33bc32-754f-41aa-b3f4-49d803c43523@e3 9g2000hsf.googl egroups.com...
    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="ret urn NoNumbers(event )" and javascript (implement the
    onkeypres event handler)
    >
    But how to implement it when using the asp:TextBox control ?
    MyTextBox.Attri butes.Add("onke ypress", "return NoNumbers(event );");


    --
    Mark Rae
    ASP.NET MVP


    Comment

    • Christian Cambier

      #3
      Re: client side validation with asp:TextBox ???

      On Jul 14, 5:58 pm, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
      "Christian Cambier" <christian.camb ...@gmail.comwr ote in message
      >
      news:9f33bc32-754f-41aa-b3f4-49d803c43523@e3 9g2000hsf.googl egroups.com...
      >
      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="ret urn NoNumbers(event )" and javascript (implement the
      onkeypres event handler)
      >
      But how to implement it when using the asp:TextBox control ?
      >
      MyTextBox.Attri butes.Add("onke ypress", "return NoNumbers(event );");
      >
      --
      Mark Rae
      ASP.NET MVPhttp://www.markrae.net
      thank you for the great tip!

      Chris

      Comment

      Working...