Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Help

Help

Scheduled Pinned Locked Moved ASP.NET
help
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    musnet2007
    wrote on last edited by
    #1

    i need a code to i want to validate a textbox, it should take only numeric value before entering to the next filed. mus

    M J S 3 Replies Last reply
    0
    • M musnet2007

      i need a code to i want to validate a textbox, it should take only numeric value before entering to the next filed. mus

      M Offline
      M Offline
      Michael Sync
      wrote on last edited by
      #2

      You should google a lit bit... function getKeyCode(e) { if (window.event) return window.event.keyCode; else if (e) return e.which; else return null; } function keyRestrict(e, validchars) { var key='', keychar=''; key = getKeyCode(e); if (key == null) return true; keychar = String.fromCharCode(key); keychar = keychar.toLowerCase(); validchars = validchars.toLowerCase(); if (validchars.indexOf(keychar) != -1) return true; if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 ) return true; return false; }

      <input type="text" name="textfield" onKeyPress="return keyRestrict(event,'1234567890')">

      Thanks to this "http://www.codeproject.com/useritems/keyboard_restrict_spanish.asp[^]" https://www.aspnetpro.net/newsletterarticle/2004/01/asp200401de_l/asp200401de_l.asp more

      Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

      1 Reply Last reply
      0
      • M musnet2007

        i need a code to i want to validate a textbox, it should take only numeric value before entering to the next filed. mus

        J Offline
        J Offline
        John ph
        wrote on last edited by
        #3

        How about restricting the user from entering alphabets or special characters Instead of validating the entered text. check for the keycode using javascript on the keyPress or KeyDown event of the textbox . if the keycode falls between 48 and 57 then the entered key is a number ortherwise return false. when the return value is false it doesn't take the entered value.... function onlynumbers(){ if (window.event.keyCode>=48 && window.event.keyCode<=57){ window.event.returnValue = true; } else window.event.returnValue = false; }

        Regards
        J O H N :rose:
        "Even eagles need a push." David McNally



        1 Reply Last reply
        0
        • M musnet2007

          i need a code to i want to validate a textbox, it should take only numeric value before entering to the next filed. mus

          S Offline
          S Offline
          Sathesh Sakthivel
          wrote on last edited by
          #4

          Before Posting the Question in the Forum Just read the Guidelines and post the question with the appropriate Subject. What is there with the " Help".

          SSK.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups