Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   Javascript language for counting characters (https://www.askmehelpdesk.com/showthread.php?t=182896)

  • Feb 11, 2008, 12:32 PM
    boobiesonthetree
    Javascript language for counting characters
    I wonder if anyone can help me please,

    I am trying to write code into my program
    The code needs to be for counting characters in a password
    The user enters a password which must be between 7-15 characters long
    If the user enters outsuide this rule then an error message must come up stating exactly how many characters the user did enter and telling them it must be between 7-15 characters.
    I have managed to do the error message for the wrong amount of characters but I can't get my head around displaying the amount of characters the user entered
    If anybody can help pleaseeeee do thank you

    Emma
  • Mar 31, 2008, 08:39 AM
    manchester thani
    Try using indexAt and charAt methods buddy... but I am not sure..
  • Apr 9, 2008, 01:40 PM
    jstrike
    Code:

    function checkPassLength(password);
      var passLen = password.length;
      if(passLen<7) {
        alert("You entered " + passLen + " characters, your password is too short.");
        return false;
      }

      if(passLen>15) {
        alert("You entered " + passLen + " characters, your password is too long.");
        return false;
      }

      return true;
    }


  • All times are GMT -7. The time now is 03:24 AM.