ITsolutionWizard
asked on
javascript, age, keydown
I already have onkeydown for one function called dateformat
My goal is if someone enter date format like 01/01/1972, it will call another function called 'CheckAge' and I want to show the value inside of the <div id="getage"></div>
How can i do that?
My goal is if someone enter date format like 01/01/1972, it will call another function called 'CheckAge' and I want to show the value inside of the <div id="getage"></div>
How can i do that?
function DateFormat(txt, keyCode) {
if (keyCode == 16)
isShift = true;
//Validate that its Numeric
if (((keyCode >= 48 && keyCode <= 57) || keyCode == 8 ||
keyCode <= 37 || keyCode <= 39 ||
(keyCode >= 96 && keyCode <= 105)) && isShift == false) {
if ((txt.value.length == 2 || txt.value.length == 5) && keyCode != 8) {
txt.value += seperator;
}
return true;
}
else {
return false;
}
}
function CheckAge(dateString)
{
if (dateString != '') {
var today = new Date();
var birthDate = new Date(dateString);
var age = today.getFullYear() - birthDate.getFullYear();
var m = today.getMonth() - birthDate.getMonth();
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
alert(age);
}
else
{
alert("No Age");
}
return age;
}
<div id=GetAge></div>
<div class="ui-input">
<input type="date" required tabindex="3" maxlength="10" name="dob" id="dob" onkeydown="return DateFormat(this, event.keyCode)" placeholder="Enter DOB" value="<%= GetDOB(Request.QueryString["Primary DOB"]) %>" class="form-control" />
<label class="ui-icon"><i class="fa fa-birthday-cake"></i></label>
<p id="exactAge"></p>
</div>
try something like this
ASKER
can you integrate your codes with my codes?
can you integrate your codes with my codes?Unfortunately no since I have no idea what this is in your code:
<%= GetDOB(Request.QueryString["Primary DOB"]) %>
ASKER
You can take off the value if it bothers you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Question inactive
ASKER