js username validator code example
Example: username validation js
<!DOCTYPE html>
<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>