Hi, I am new member here and this is my first post.
I am having prob.
i want to validate user dob (only year) using java script.
1-else if age is less then 20 message should be "not enough"
2-else message should be "welcome".
But it show "welcome" message if field is empty. please check and help me.any help will be appreciated.
<html>
<head>
<title>
This is dob validation
</title>
<script language="javascript">
function dobvali()
{
var currentdate=new Date();
var yearonly=currentdate.getFullYear();
var usrdob=document.getElementById('dob').value;
var res=yearonly-usrdob;
if(res<20)
{
alert('not enough');
}
else
{
alert('welcome');
}
}
</script>
</head>
<body>
Enter DOB (DD/MM/YYYY):<input type="text" id="dob"/>
<input type="button" value="check" onClick="dobvali();"/>
</body>
</html>