R
Rich
Hello,
I'm learning JavaScript.........or Trying to and am stuck.
My old brain is just not understanding why this isn't working.
Internet Explorer reports an error but the error is Cryptic to me.
Any Help would be Greatly Appreciated.
THANKS!
My Goal
-------------------------------------------------
Write a set of functions that check for a legal drinking age.
I want it to include a data validation function(s) which will check the date
and prompt the user if the date is entered incorrectly or contains invalid
characters.
------------------------------------------------------------------------
My Broken Script
==========================================
<HTML>
<HEAD>
<TITLE>Legal Drinking Age Meter </TITLE>
</HEAD>
<BODY>
<script language="JavaScript" type="text/JavaScript">
var mm = prompt('What month were you born in?','1-12');
var bday = prompt('What day were you born on?','1-31');
var byear = prompt('What year were you born in?','1975');
document.write("<b>You were born on "+bmonth+" "+bday+", "+byear+".
("+mm+"/"+bday+"/"+byear+")</b>");
document.write("<br><br>I am "+yourage+" years old, and will turn "+age2+"
in:");
var ageString;
var legalAge=21;
var ageNumber;
ageString = prompt ("Please enter your age", " ");
ageNumber = parseInt(ageString);
document.write(ageString + "<br>");
document.write(ageNumber + "<br>");
document.write(legalAge + "<br>");
if (ageNumber >= legalAge)
{alert ("Let's Party!");}
else if (ageNumber < legalAge)
{alert ("Sorry! You're too young to drink!");}
else if (ageNumber < 0)
{alert ("Please enter a valid age"); }
else
{alert ("Please enter a valid age"); }
alert ("end of script");
</SCRIPT>
</BODY>
</HTML>
I'm learning JavaScript.........or Trying to and am stuck.
My old brain is just not understanding why this isn't working.
Internet Explorer reports an error but the error is Cryptic to me.
Any Help would be Greatly Appreciated.
THANKS!
My Goal
-------------------------------------------------
Write a set of functions that check for a legal drinking age.
I want it to include a data validation function(s) which will check the date
and prompt the user if the date is entered incorrectly or contains invalid
characters.
------------------------------------------------------------------------
My Broken Script
==========================================
<HTML>
<HEAD>
<TITLE>Legal Drinking Age Meter </TITLE>
</HEAD>
<BODY>
<script language="JavaScript" type="text/JavaScript">
var mm = prompt('What month were you born in?','1-12');
var bday = prompt('What day were you born on?','1-31');
var byear = prompt('What year were you born in?','1975');
document.write("<b>You were born on "+bmonth+" "+bday+", "+byear+".
("+mm+"/"+bday+"/"+byear+")</b>");
document.write("<br><br>I am "+yourage+" years old, and will turn "+age2+"
in:");
var ageString;
var legalAge=21;
var ageNumber;
ageString = prompt ("Please enter your age", " ");
ageNumber = parseInt(ageString);
document.write(ageString + "<br>");
document.write(ageNumber + "<br>");
document.write(legalAge + "<br>");
if (ageNumber >= legalAge)
{alert ("Let's Party!");}
else if (ageNumber < legalAge)
{alert ("Sorry! You're too young to drink!");}
else if (ageNumber < 0)
{alert ("Please enter a valid age"); }
else
{alert ("Please enter a valid age"); }
alert ("end of script");
</SCRIPT>
</BODY>
</HTML>