<html>
<head>
<title>Age Calculator</title>
<script type=”text/javascript”>
<form id=”calculator”>
<label for=”age”>How old are you in years? </label>
<input id=”age” type=”number” min=”0″ />
</form>
<p>You are (at least) <span id=”result”>0</span> days old.</p>
{
$(document).ready(function() {
$(“#age”).change(function(event) {
age = $(“#age”).val();
$(“#result”).text(addCommas(Math.floor(age * 365.25)));
});
});
function addCommas(nStr)
{
nStr += ”;
x = nStr.split(‘.’);
x1 = x[0];
x2 = x.length > 1 ? ‘.’ + x[1] : ”;
var rgx = /(d+)(d{3})/;
while (}rgx.test(x1)) {
x1 = x1.replace(rgx, ‘$1’ + ‘,’ + ‘$2’);
}
return x1 + x2;
}
</script>
</head>
</body>
</html>
I am trying to make an age calculator, so that the page displays a box and you type in how old you are in the box and it gives you your age in DAYS and this is what I have so far, but its not working and I dont know whats wrong. I also want to add like If the AGE is less then ZERO it wont work, or if the Age is greater than 120 It wont work. How do I add that line so it makes the program not work or say type in another age or something like that? beginner with java here ><