i have form element of date type:
<input type="date" class="form-control" name="inputdob" id="dob" placeholder="dob" onblur="datevalidate()" required>
the javascript code here:
function datevalidate(){ var date=new date(); var pass1 = document.getelementbyid("dob"); alert(pass1.value); var date = new date(); today=date.getfullyear()+'-'+(date.getmonth() + 1)+'-'+date.getdate(); if(pass1.value<today){ alert("date correct "); } }
you don't need today
, change if
if(new date(pass1.value)< date){ alert("date correct "); } //or if(new date(pass1.value)< new date()){ alert("date correct "); }
Comments
Post a Comment