Restrict MaxLength

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krisnacreddy1
    New Member
    • Jan 2008
    • 3

    Restrict MaxLength

    I put MaxLength of text box is "10". After entering "." it is not allowing more than 2numbers. How to restrict it?. Ex:- 10.34, After than it is not allowing any letters.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Welcome to TSDN!

    Use onkeypress and check each key pressed. If the dot key has been pressed, check that only two more number keys are pressed. To prevent a key being entered, just return false as shown in the example on the linked page.

    Comment

    • krisnacreddy1
      New Member
      • Jan 2008
      • 3

      #3
      i cant get u. please replay clearly

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Before that, I think you should clearly explain the question properly.

        Instead of restricting the maxlength, just restrict the key presses - see the linked page.

        Comment

        • krisnacreddy1
          New Member
          • Jan 2008
          • 3

          #5
          After Enter "." it wont allow more than 2 characters. How to restrict that.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            I'm not sure I understand what you mean. If it doesn't allow already then there's no need to restrict the input.

            By restricting, it would mean not allowing.

            I think it'd be better if you post what code you have so far then we can work from there.

            Comment

            Working...