![]() |
Setting the minimum length of a password facilitates notifying the user to insert the min. password length, without leaving the field vacant while submitting the form. This helps to authenticate the user and also ensures that users create sufficiently strong passwords that are harder to guess or crack. Setting a minimum length for passwords is a common practice to enhance security in web applications. Table of Content Using the pattern AttributeOne approach is to use the pattern attribute in conjunction with a regular expression to enforce a minimum password length. Here, the pattern=”.{8,}” attribute is applied to the password input field. This regular expression {8,} ensures that the password contains at least 8 characters. Example:
Output: ![]() Set Minimum Length of Password with pattern Attribute Using the minlength AttributeThe minlength attribute can be used to specify the minimum length directly without the need for a regular expression. Here, the minlength=”8″ attribute is used to set the minimum length of the password to 8 characters. Example:
Output: ![]() Set Minimum Length of Password with minlength Attribute |
Reffered: https://www.geeksforgeeks.org
Geeks Premier League |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |