form input minimum length

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Supaflyz
    Confirmed User
    • May 2005
    • 151

    #1

    form input minimum length

    Been searching on google for a form validator like the old tgp/mgp sites used to have.

    It would tell you how many characters you had typed, and show in red or green when you had inputted enough characters for form to be submitted.

    If anyone has a link be much appreciated.
  • BJ
    Confirmed User
    • Mar 2002
    • 5590

    #2
    I only have purple or orange

    Comment

    • cyber
      Confirmed User
      • Jan 2004
      • 182

      #3
      Code:
      <script language="javascript" type="text/javascript">
      function verifyLength(str, num, checkID){
        var str = document.getElementById(str).value;
        var good = "Your input is long enough";
        var bad = "Your input is too short";
      
        if(str.length >= num){
          document.getElementById(checkID).innerHTML = good;
          document.getElementById(checkID).className = "verify"
        }
        else{
          document.getElementById(checkID).innerHTML = bad;
          document.getElementById(checkID).className = "verify red"
        }
      }
      </script>
      Usage:

      Code:
          <div>
            <label>Password. Minimum 6 characters.<br />
              <input type="password" name="registerFormPassword" id="registerFormPassword" class="field" value="" tabindex="3"
                onkeyup="javascript:verifyLength('registerFormPassword', '6', 'verifyLengthregisterFormPassword');" />
            </label>
            <br />
            <span id="verifyLengthregisterFormPassword" class="verify">&nbsp;</span>
          </div>
      Check my signature for custom PHP/Javascript/MySQL programming!

      Comment

      • seeandsee
        Check SIG!
        • Mar 2006
        • 50945

        #4
        js for the win
        BUY MY SIG - 50$/Year

        Contact here

        Comment

        • Supaflyz
          Confirmed User
          • May 2005
          • 151

          #5
          Thanks very much, i'll try that code out.

          Comment

          • fris
            Too lazy to set a custom title
            • Aug 2002
            • 55679

            #6
            try some jquery action

            http://speckyboy.com/2009/12/17/10-u...d-tutorials-2/
            Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

            Comment

            Working...