Hi there jsnewbie,
and a warm welcome to these forums. 
Regular Expressions aren't my forte and someone will probably come up with something a little more precise
but this example, hopefully, should do the job for now...
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
window.onload=function(){
var pattern=/^([a-zA-Z0-9])([a-zA-Z0-9_-]*)([a-zA-Z0-9])$/;
var df=document.forms[0];
df[1].onclick=function(){
if(df[0].value.match(pattern)){
alert('This is a match');
}
else {
alert('This is not a match');
}
}
}
</script>
</head>
<body>
<form action="#">
<div>
<input type="text">
<input type="button" value="check">
</div>
</form>
</body>
</html>
coothead
Bookmarks