ok brother thanks so much for your reply, but there is an other confusion.
According to my understanding the logic that you have used in if else if statement is that ,when a user incomplete year or left the field empty it gives error message "fill this", but if i enter 19 or 198 that is incomplete value it show message "Welcome". That makes me confused please explain it.
Thanks.
<html>
<head>
<title>
This is dob validation
</title>
<script type="text/javascript">
function dobvali(){
var currentdate = new Date();
var yearonly = currentdate.getFullYear();
var usrdob = document.getElementById('dob').value;
var res = yearonly-usrdob;
if (!usrdob || isNaN(usrdob))
{
alert('fill this');
}
else if (res < 20)
{
alert('not enough');
}
else
{
alert('welcome');
}
}
</script>
</head>
<body>
Enter DOB (DD/MM/YYYY):<input type="text" id="dob" maxlength="10"/>
<input type="button" value="check" onClick="dobvali()"/>
</body>
</html>