|
↑
Calculators >>>
Enter the mother's pregnancy information into this calculator and JavaScript will provide an estimated conception date, birth due date, and an estimated current fetal age. Great for all those mothers-to-be!
Add the below code to the <body> section of your page:
<script language="javascript" type="text/javascript"> function isValidDate(dateStr) {
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; var matchArray = dateStr.match(datePat); if (matchArray == null) { alert("Date is not in a valid format.") return false; } month = matchArray[1]; day = matchArray[3]; year = matchArray[4]; if (month < 1 || month > 12) { alert("Month must be between 1 and 12."); return false; } if (day < 1 || day > 31) { alert("Day must be between 1 and 31."); return false; } if ((month==4 || month==6 || month==9 || month==11) && day==31) { alert("Month "+month+" doesn't have 31 days!") return false; } if (month == 2) { var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); if (day>29 || (day==29 && !isleap)) { alert("February " + year + " doesn't have " + day + " days!"); return false; } } return true; }
function dispDate(dateObj) { month = dateObj.getMonth()+1; month = (month < 10) ? "0" + month : month;
day = dateObj.getDate(); day = (day < 10) ? "0" + day : day;
year = dateObj.getYear(); if (year < 2000) year += 1900;
return (month + "/" + day + "/" + year); }
function pregnancyCalc(pregform) { menstrual = new Date(); ovulation = new Date(); duedate = new Date(); today = new Date(); cycle = 0, luteal = 0; if (isValidDate(pregform.menstrual.value)) { menstrualinput = new Date(pregform.menstrual.value); menstrual.setTime(menstrualinput.getTime()) } else return false; cycle = (pregform.cycle.value == "" ? 28 : pregform.cycle.value); if (pregform.cycle.value != "" && (pregform.cycle.value < 22 || pregform.cycle.value > 45)) { alert("Your cycle length is either too short or too long for \n" + "calculations to be very accurate! We will still try to \n" + "complete the calculation with the figure you entered. "); }
luteal = (pregform.luteal.value == "" ? 14 : pregform.luteal.value); if (pregform.luteal.value != "" && (pregform.luteal.value < 9 || pregform.luteal.value > 16)) { alert("Your luteal phase length is either too short or too long for \n" + "calculations to be very accurate! We will still try to complete \n" + "the calculation with the figure you entered. "); }
ovulation.setTime(menstrual.getTime() + (cycle*86400000) - (luteal*86400000)); pregform.conception.value = dispDate(ovulation);
duedate.setTime(ovulation.getTime() + 266*86400000); pregform.duedate.value = dispDate(duedate);
var fetalage = 14 + 266 - ((duedate - today) / 86400000); weeks = parseInt(fetalage / 7); days = Math.floor(fetalage % 7); fetalage = weeks + " week" + (weeks > 1 ? "s" : "") + ", " + days + " days"; pregform.fetalage.value = fetalage;
return false; } </script> <form onSubmit="return pregnancyCalc(this);"> <table> <tr><td> <pre> Last Menstrual Period: <input type=text name=menstrual value="" size=10 maxlength=10> (MM/DD/YYYY format)
Average Length of Cycles: <input type=text name=cycle value="" size=3 maxlength=3> (22 to 45) (defaults to 28)
Average Luteal Phase Length: <input type=text name=luteal value="" size=3 maxlength=3> (9 to 16) (defaults to 14)
<center><input type=submit value="Calculate!"></center>
Estimated Conception: <input type=text name=conception value="" size=20> Estimated Due Date: <input type=text name=duedate value="" size=20> Estimated Fetal Age: <input type=text name=fetalage value="" size=20> </pre> </td></tr> </table> </form>
|
→ online casino in Canada
|