Jsp code for validating username and password
If you're concerned about security you should have some policy on what constitutes a valid password.
Some common restrictions are: Leaving the last requirement for now, as it requires a server-side script, let's see what's possible using just client-side HTML and Java Script.
While having a strong password is a good first step, it needs to be backed up by additional measures on the server that prevent brute-force attacks.
One popular approach is to install Fail2Ban to monitor log files and lock out repeat offendors.
In any case browsers such as Firefox and Opera will enforce the HTML5 validation rules and present messages as shown here: Presumably the browser messages will change according to the users language - something that would never be possible using only Java Script.
All we have changed from the previous example is to add some extra attributes to the form input fields.
Consider the following: If you are using a supported browser you can use the form below to test the regular expression: If you want to restrict the password to ONLY letters and numbers (no spaces or other characters) then only a slight change is required.The simplest way to do this is to have the password entered twice, and then check that they are identical.