Programming with JavaScript

⌘K
  1. Home
  2. Docs
  3. Programming with JavaScri...
  4. Example Programs
  5. Checker to validate password

Checker to validate password

Example 37

Write a JavaScript function called checker to validate the password length (Length must be 10), where username and password get through html.

Code

<html>
    <head>
        <title> Form input </title>
    </head>
    <body>
        <form name="forma">
            username :   <input type="text" name="tb1" id="tb1"> <br> <br>
            password :   <input type="password" name="tb2" id="tb2"> <br> <br>
            <input type = "button" value = "CheckValidity" id = b1 onclick="Checker(document.forma.tb2.value)"> <br>

            <script>
                function Checker(st)
                {
                    if(st.length < 10)
                    {
                        alert(`${st.length} password length should be atmost 10 characters`)
                    }
                }
            </script>
         
    </body>
</html>

Output

Loading

Views: 124

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments