Textbox validation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arial
    New Member
    • Sep 2007
    • 109

    Textbox validation

    Ok.. I need help again.

    I have a text box in my web form, so I am trying to do is as soon as user enters anything in text box other than 1....9,0 I have to give them a message saying invalid input.

    How can I check user input an give them a message?

    Thank You,
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    On a webform you will need to have a javascript function that watches the onkeydown() (or similar) function.

    Comment

    • arial
      New Member
      • Sep 2007
      • 109

      #3
      I have a asp.net webform using c#.

      My textbox is:
      <asp:textbox id="txtqanum" runat="server"> </asp:textbox>

      this one does not have a property of keypress,onblur etc.

      I was thinking to compare it so asci value but ,how can compare that value entered in textbox to asci value?

      like asc(txtqanum.te xt)

      help me on this.

      Thank You,

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        This does not work:
        Code:
        <asp:textbox id="txtqanum" onkeydown="SomeJavaScriptFunction();" runat="server"></asp:textbox>

        Comment

        • arial
          New Member
          • Sep 2007
          • 109

          #5
          I don't get Onkeydown event handler.

          I got the javascript function but I don't know where to call it.

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            It won't show up in the autocomplete.
            An alternative is in the backend code, find that textbox control and do an AddAttribute() (I think that's the right name) for something like:
            Code:
            txtqanum.AddAttribute("onkeydown","SomeJavaScriptFunction();");

            Comment

            Working...