Code for validating username and password in jsp

In our example, we have a login form with two input fields i.e.

code for validating username and password in jsp-45

The problem here is that you're making the password visible in the browser, browser cache, proxy, etc.

For security a password should never be displayed in HTML or sent by email.

The simplest way to do this is to have the password entered twice, and then check that they are identical.

Another method is to display what they've entered as part of a 'confirmation page'.

We're going to show you now how to apply the password tests using a single regular expression.

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.

After all it's only the browser display being obfuscated and not the data transfer.

Because the input type obscures the text typed, you should let the user confirm that they haven't made a mistake.

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.

Some text editors (not just vi) also allow them when searching for or replacing text. This is a new technique available in modern browsers and definitely the way of the future.

Tags: , ,