common username validation code example
Example: username validation
<html>
<head>
<title></title>
</head>
<body>
<form method="post" action="">
username:<input type="text" id="name" onkeyup="validation()">
</form>
</body>
<script type="text/javascript">
function validation(){
var username=document.getElementById("name").value;
var usernamepattern=/^[A-Za-z .]{3,15}$/;
if(usernamepattern.test(username))
{
document.getElementById("name").style.backgroundColor='yellow';
}
else
{
document.getElementById("name").style.backgroundColor='red'; }
}
</script>
</html>