form validation example using javascript

<html>
<head>
<script>

function check_valid(str)
{
 var name=document.getElementById("username").value;
 if(name=="")
 {
 document.getElementById("lb1").innerHTML="enter your name";

 }

}

</script>
</head>
<form action="#" method="POST" name="form">

student user name:<input type="text" id=username  name="username" onblur="check_valid(this.value)">
<br>
<div id="lb1" style="color:red";></div>

<input id="ok" style="margin-left: 74px;" type="submit" name="submit" value="create account!!">
</form>
</body>
</html>


Previous
Next Post »

2 comments

Write comments
19 April 2017 at 04:16 delete

Thanks for sharing, please do post on Codelobster

Reply
avatar
Garima Ahuja
AUTHOR
23 October 2017 at 02:29 delete

please check this link for checking https://sisgain.com/hire-node-js-developer

Reply
avatar