Click to See Complete Forum and Search --> : validate alphanumeric


dyn
04-22-2003, 02:57 AM
can anyone tell me how to validate a field where it MUST be alphanumeric (password security)

Charles
04-22-2003, 04:36 AM
<!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">
<form action="">
<div>
<label for="pswrd">Password</label>:<br>
<input type="password" onchange="if (!/^[\w\d]+$/.test(this.value)) {alert('This field requires alphanumeric characters.'); this.value =''}"><br>
<input type="submit" value="Submit">
<div>
</form>

Charles
04-22-2003, 12:55 PM
Good catch Dave. Thanks.

Vladdy
04-22-2003, 12:59 PM
Or you can do this:

<label>Password: <input ... > </label>