Click to See Complete Forum and Search --> : Form Pasword Validator


mmendez_pr
08-19-2003, 01:11 PM
Hi I need to validate a pasword. It has to be alphanumeric (A-Z and 1-9) but at least one number is require. How can I do this?

Nevermore
08-19-2003, 01:35 PM
Can the number be anywhere?

Charles
08-19-2003, 01:44 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Example</title>
<script type="text/javascript">
<!--
String.prototype.isPassword = function () {return (/^[\w\d]*$/.test(this) && /\d/.test(this))}
// -->
</script>
<form action="">
<div>
<input type="password" onchange="if (!this.value.isPassword()) {alert('That does not appear to be a valid password.'); this.value = ''; this.focus()}">
</div>
</form>

mmendez_pr
08-19-2003, 01:45 PM
Yes the number can be anywhere!!

Charles
08-19-2003, 01:48 PM
Then give my example a try.

mmendez_pr
08-19-2003, 02:27 PM
the code you pass me is working fine...:D