Answers for "username validation in javascript"

0

username validation in javascript

function validateUserName(username){
  var usernameRegex = /^[a-zA-Z0-9]+$/;
  return usernameRegex.test(username);
}
Posted by: Guest on January-27-2021
1

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;///get id with value 
	var usernamepattern=/^[A-Za-z .]{3,15}$/;////Regular expression
	if(usernamepattern.test(username))
	{
		document.getElementById("name").style.backgroundColor='yellow';
    }
    else
    {
    	document.getElementById("name").style.backgroundColor='red'; }
	}

</script>
</html>
Posted by: Guest on January-24-2021

Code answers related to "username validation in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language