JSFiddle - React, Tailwind, and code Playground
HTML
<script src="mypokerpartner.com/maskedInput.js"></script>
<script src="mypokerpartner.com/cookie.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript" src="http://www.mypokerpartner.com/cookie.js"></script>
<script type="text/javascript" src="http://www.mypokerpartner.com/timeAgo.js"></script>
<script type="text/javascript" src="http://www.mypokerpartner.com/maskedInput.js"></script>
<form action="enter.php" method="post" id="Form">
<p class="inputs">
<input name="DAY" type="text" id="txtMonth" placeholder="MM" maxlength="2" autocomplete="off" />
<input name="MONTH" type="text" id="txtDay" placeholder="DD" maxlength="2" autocomplete="off" />
<input name="YEAR" type="text" id="txtYear" placeholder="YYYY" maxlength="4" autocomplete="off" />
</p>
<p class="jqtransform remember"><label><input type="checkbox" id="remember" />Remember me</label></p>
<a href="javascript:void(0)" class="enter" id="submit">submit</a><br /><br />
<a href="javascript:void(0)" class="deleteCookie">Delete Cookie</a><br /><br />
<div style="clear:both;"></div>
</form>
<div id="invalidDOB" class="errorMsg">Please enter a valid date of birth.</div>
<div id="tooYoung" class="errorMsg">You're too young.</div>
CSS
.errorMsg {
display: none;
width: 50%;
border: 1px solid #aaa;
padding: 3px;
text-align: center;
margin: 0px auto;
border: 1px solid #8F1515;
border-radius: 5px;
font: 10pt Verdana;
background-color: #F2C2CE;
}
JavaScript
$('input[name="DAY"]').mask("99");
$('input[name="MONTH"]').mask("99");
$('input[name="YEAR"]').mask("9999");
$('.deleteCookie').click(function() {
$.cookie('age', null);
});
$('#submit').click(function() {
var enteredDOB = $('input[name="DAY"]').val() + "/" + $('input[name="MONTH"]').val() + "/" + $('input[name="YEAR"]').val();
var age = parseInt(jQuery.timeago(enteredDOB));
if (age === 'NaN') {
$("#invalidDOB").fadeIn("slow");
} else {
$("#invalidDOB").css("display", "none"); //hide if visible
if (parseInt(age, 10) >= 21) {
$("#tooYoung").css("display", "none"); //hide if visible
alert('you\'re of age');
if ($('#remember').is(":checked")) {
$.cookie('age', age, { expires: 365 });
} else {
$.cookie('age', age);
}
alert("age: " + $.cookie('age'));
$('#Form').submit();
} else {
$("#tooYoung").fadeIn("slow");
}
}
});
if (null !== $.cookie('age')) {
alert('Saved cookie (Age: ' + $.cookie('age') + ")");
}