How to implement key press event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thomask
    New Member
    • Nov 2007
    • 2

    How to implement key press event

    Hello my friends ,

    How to implement key press event for checking whether the value entered in the text box is integer.(ie if we press any alphabetic letter in the text box, at the key press it show a message it is not allowed in the text box)

    Regards
    Thomas Kannathara
  • mathewgk80
    New Member
    • Sep 2007
    • 103

    #2
    Originally posted by thomask
    Hello my friends ,

    How to implement key press event for checking whether the value entered in the text box is integer.(ie if we press any alphabetic letter in the text box, at the key press it show a message it is not allowed in the text box)

    Regards
    Thomas Kannathara
    Hi Thomas,

    Are yu using c#.net or vb.net??
    Please specify it...

    Regards,

    Mathew

    Comment

    • thomask
      New Member
      • Nov 2007
      • 2

      #3
      Originally posted by mathewgk80
      Hi Thomas,

      Are yu using c#.net or vb.net??
      Please specify it...

      Regards,

      Mathew
      i am working in C#.net......... .........

      Comment

      • jrajeshjoseph
        New Member
        • Oct 2007
        • 1

        #4
        i am working in C#.net and ASP.Net

        Comment

        • Shashi Sadasivan
          Recognized Expert Top Contributor
          • Aug 2007
          • 1435

          #5
          Have you tried the rangeValidators available for Asp.Net ?

          you cant have a seperate keypress event for web pages.. unless you want to use ajax.

          You could use the editvaluchanged event, but that will cause a lot of postbacks and will highly affect the performance.

          Comment

          • praveen1983
            New Member
            • Jan 2008
            • 17

            #6
            Originally posted by thomask
            Hello my friends ,

            How to implement key press event for checking whether the value entered in the text box is integer.(ie if we press any alphabetic letter in the text box, at the key press it show a message it is not allowed in the text box)

            Regards
            Thomas Kannathara

            Use javascript


            function RestrictKeys(ev t)
            {
            var e=evt ? evt : window.event;

            var key =e.charCode;
            if ((key ==126) ||(key==124)&&( key!=8))
            {
            return false;
            }
            else
            return true;
            }

            Comment

            • Rajeshshewale
              New Member
              • Aug 2007
              • 8

              #7
              I have written code here:
              [Link Removed]

              Comment

              • MMcCarthy
                Recognized Expert MVP
                • Aug 2006
                • 14387

                #8
                @ Rajeshshewale

                If you wish to submit code please submit it in the thread and not using a link.

                ADMIN

                Comment

                Working...