Javascript Code for Not accepting Zero when entered alone in a Text Box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nitindel
    New Member
    • Dec 2007
    • 67

    Javascript Code for Not accepting Zero when entered alone in a Text Box

    Hi,
    I have a text Box and want to apply javascript validation for not accpting Only Zero(s). For eg. If i enter 002308 ,it should accept but if enter 00000 or any number of Zeros alone ,it shold throw Error..

    Please tell.It's Urgent.

    Thanks & Regards
    Nitin Sharma
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    Originally posted by nitindel
    Hi,
    I have a text Box and want to apply javascript validation for not accpting Only Zero(s). For eg. If i enter 002308 ,it should accept but if enter 00000 or any number of Zeros alone ,it shold throw Error..

    Please tell.It's Urgent.

    Thanks & Regards
    Nitin Sharma
    Hi nitindel
    Welcome to TSDN.

    Please post your questions in the right forum so that you can recieve a more quicker and better resposnce from the experts residing in that Forum.

    -Shashi

    Comment

    • nitindel
      New Member
      • Dec 2007
      • 67

      #3
      Originally posted by Shashi Sadasivan
      Hi nitindel
      Welcome to TSDN.

      Please post your questions in the right forum so that you can recieve a more quicker and better resposnce from the experts residing in that Forum.

      -Shashi
      Sure ...I will take care from noe onwards...
      Please tell the solution now...

      Thnaks in Advance
      Nitin Sharma

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by nitindel
        I have a text Box and want to apply javascript validation for not accpting Only Zero(s). For eg. If i enter 002308 ,it should accept but if enter 00000 or any number of Zeros alone ,it shold throw Error..
        Use a regular expression, e.g. /^[0]+$/ should match all zeros only. See this link on how to use regular expressions in JavaScript.

        Comment

        Working...