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. Textbox value must be numeric and non zero

Textbox value must be numeric and non zero

Scheduled Pinned Locked Moved ASP.NET
6 Posts 5 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.
  • R Offline
    R Offline
    Reddy1983
    wrote on last edited by
    #1

    Hi I have a textbox on page that should be numeric and non zero What can we set the ValidationExpression to validation control

    R C D 3 Replies Last reply
    0
    • R Reddy1983

      Hi I have a textbox on page that should be numeric and non zero What can we set the ValidationExpression to validation control

      R Offline
      R Offline
      rakeshs312
      wrote on last edited by
      #2

      You can use this javascript function Place a HTML text box (here its name is Text1)and onBlur event write a function function abc() { var res=document.getElementById("Text1").value; if(isNaN(res)|| document.getElementById("Text1").value==0) { document.form1.Text1.value=""; } }

      modified on Wednesday, March 4, 2009 5:28 AM

      1 Reply Last reply
      0
      • R Reddy1983

        Hi I have a textbox on page that should be numeric and non zero What can we set the ValidationExpression to validation control

        C Offline
        C Offline
        codingrocks
        wrote on last edited by
        #3

        Put the validation expression as validationexpression=\d{0,10} its only accepting only integer values in the range 0 to 10 or Change it to ValidationExpression="[0-9]*"

        SAJAN A PILLAI ASP.NET,C#.NET Programmer BANGALORE "Winners don't do different things. They do things differently. ...

        modified on Wednesday, March 4, 2009 5:25 AM

        R 1 Reply Last reply
        0
        • C codingrocks

          Put the validation expression as validationexpression=\d{0,10} its only accepting only integer values in the range 0 to 10 or Change it to ValidationExpression="[0-9]*"

          SAJAN A PILLAI ASP.NET,C#.NET Programmer BANGALORE "Winners don't do different things. They do things differently. ...

          modified on Wednesday, March 4, 2009 5:25 AM

          R Offline
          R Offline
          Reddy1983
          wrote on last edited by
          #4

          I want accecpt all integer and non zero

          J 1 Reply Last reply
          0
          • R Reddy1983

            I want accecpt all integer and non zero

            J Offline
            J Offline
            J4amieC
            wrote on last edited by
            #5

            You could use a comparevalidator to check the value is greater than 0

            1 Reply Last reply
            0
            • R Reddy1983

              Hi I have a textbox on page that should be numeric and non zero What can we set the ValidationExpression to validation control

              D Offline
              D Offline
              dan sh
              wrote on last edited by
              #6

              You can use regex to find if the entered data is a "Natural Number". Google will help you find it. Also, make sure that the regex should NOT have a check that text begins with 0. Reason being user can enter 0000003434 which is a valid entry as per your criteria.

              Time is the best teacher; unfortunately it kills all of its students. जय हिंद

              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