Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">
<head>
<meta charset="utf-8">
<title>IMMUNIZATION SCHEDULE</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css">
<!--
body {
    background-color:#F7F7F7;
}
.style2 {font-size: 18px; }
-->
</style>
</head>
<script language="JavaScript">
// JavaScript Document
function validatedate(inputText)
  {
          var dateformat = /^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/;
  // Match the date format through regular expression
          if(inputText.value.match(dateformat))
          {
              document.form1.text1.focus();
  //Test which seperator is used '/' or '-'
              var opera1 = inputText.value.split('/');
              var opera2 = inputText.value.split('-');
              lopera1 = opera1.length;
              lopera2 = opera2.length;
  // Extract the string into month, date and year
              if (lopera1>1)
              {
                  var pdate = inputText.value.split('/');
              }
              else if (lopera2>1)
              {
                  var pdate = inputText.value.split('-');
              }
          var dd = parseInt(pdate[0]);
          var mm  = parseInt(pdate[1]);
          var yy = parseInt(pdate[2]);
          var ww=parseInt(pdate[3]);
  // Create list of days of a month [assume there is no leap year by default]
          var ListofDays = [31,28,31,30,31,30,31,31,30,31,30,31];
          if (mm==1 || mm>2)
          {
              if (dd>ListofDays[mm-1])
              {
                  alert('Please Enter Date!');
                  return false;
              }
          }
          if (mm==2)
          {
              var lyear = false;
              if ( (!(yy % 4) && yy % 100) || !(yy % 400))
              {
                  lyear = true;
              }
              if ((lyear==false) && (dd>=29))
              {
                  alert('Invalid date format!');
                  return false;
              }
              if ((lyear==true) && (dd>29))
              {
                  alert('Invalid date format!');
                  return false;
              }
          }
      }
      else
      {
          alert("Please Enter Date!");
          document.form1.text1.focus();
          return false;
      }

      document.form1.text2.value=document.form1.text1.value;
      document.form1.text3.value=document.form1.text1.value;

    //After 6th week Date
      var dt=MyDate(document.form1.text1.value);
      alert(dt);
      var tmp;
      if (dt.getDate()<10)
      {   tmp="0"+dt.getDate();}
      else
      {   tmp=dt.getDate();}
      if (dt.getMonth()<9)
      {   tmp=tmp+"/"+"0"+(dt.getMonth()+1);}
      else
      {   tmp=tmp+"/"+(dt.getMonth()+1);}

      var tmp=tmp+"/"+dt.getFullYear();
      document.form1.hepb.value=tmp;
      document.form1.hepbh.value=tmp;
      document.form1.bcg.value=tmp;
      document.form1.bcgh.value=tmp;
    //After 6th week date--(6weeks*7days=42)
      dt.setDate(dt.getDate()+42);
      document.form1.pen1.value=dt.toDateString();
      document.form1.penh1.value=dt.toDateString();
    //after 10th week date-- Alredy 6 weeks added (10-6=4*7=28)
      dt.setDate(dt.getDate()+28);
      document.form1.pen2.value=dt.toDateString();
      document.form1.penh2.value=dt.toDateString();
     //After 14th week date(14-10=4*7=28)
      dt.setDate(dt.getDate()+28);
      document.form1.pen3.value=dt.toDateString();
      document.form1.penh3.value=dt.toDateString();
     //After 9 month date
     // dtt.setMonth(dt.getMonth()+9); already 14weks over (9month*4weeks=36weeks) 36-14=22weeks+21days(7*3),, (22+3)=25*7=175
      dt.setDate(dt.getDate()+175);
      document.form1.meas.value=dt.toDateString();
      document.form1.meash.value=dt.toDateString();
}

function MyDate(dtstr)
{
    var str=dtstr;
    var tdt=new Date(str.substring(6,10),str.substring(3,5)-1,str.substring(0,2));
    return tdt;
}
</script>
<body onload='document.form1.text1.focus()'>
<BR>
<h1>
<center>KNOWN YOUR CHILD IMMUNIZATION SCHEDULE</center></h1>
<form name="form1"  id="form1" action="immmuni.asp" onsubmit="returnvalidatedate()">
  <h3 align="center">DATE OF BIRTH
    <input type='text' name='text1' maxlength="10"/>
    <input type="Button" name="submit" id="submit"  value="Submit" type="submit" onclick="validatedate(document.form1.text1)"/>
<input type="reset" name="reset" id="reset" value="Reset" />
</center>
&nbsp;</h3>
  <p align="center">[dd/mm/yyyy or dd-mm-yyyy format]</p>
    <table align="center" border="1">
        <tr bgcolor="#FF9966"><th width="315" height="38">
            <div align="left" class="style2">
            <div align="center">DATE OF BIRTH</div></th>
            <th width="192"><input type="text" disabled=true name="text2" id="text2" size="20">
            <th width="192"><input type="text" disabled=true name="text3" id="text3" size="20">
        </tr>
     <tr>
          <th height="43" bgcolor="#FF6633"><div align="center">VACCINES</div></th>
          <th bgcolor="#FF6633"><div align="center">DUE DATE</div></th>
          <th bgcolor="#FF6633"><div align="center">IMMUNIZATION DATE IN GHs</div></th>
    </tr>
     <tr bgcolor="#FF99CC">
         <td height="42"><strong>Hep B Birth Dose (Within 24 hours)</strong></td>
         <td align="center"><input type="text"  disabled=true name="hepb" id="hepb" size="20"></td>
         <td align="center"><input type="text"  disabled=true name="hepbh" id="hepbh" size="20"></td>
     </tr>
     <tr>
         <td height="42" bgcolor="#FFCCCC"><strong>BCG, Polio Zero Dose </strong></td>
         <td bgcolor="#FFCCCC" align="center"><input type="text" disabled=true name="bcg" id="bcg" size="20"></td>
         <td bgcolor="#FFCCCC" align="center"><input type="text" disabled=true name="bcgh" id="bcgh" size="20"></td>
     </tr>
     <tr bgcolor="#FF99CC"><td height="41" bgcolor="#FF99CC"><strong>Pentavalent-1, Polio 1st Dose (After 6th Week)</strong></td>
         <td align="center"><input type="text"  disabled=true name="Pen1" id="pen1"  size="20"></td>
         <td align="center"><input type="text"  disabled=true name="Penh1" id="penh1"  size="20"></td>
     </tr>
     <tr bgcolor="#FFCCCC"><td height="46"><strong>Pentavalent-2, Polio 2nd Dose (After 10th Week)</strong></td>
         <td align="center"><input type="text"  disabled=true name="Pen2" id="pen2"  size="20"></td></td>
         <td align="center"><input type="text"  disabled=true name="Penh2" id="penh2"  size="20"></td></td>
    </tr>
     <tr bgcolor="#FF99CC"><td height="39"><strong>Pentavalent-3, Polio 3rd Dose (After 14th week)</strong></td>
         <td align="center"><input type="text"  disabled=true name="Pen3" id="pen3"  size="20"></td></td>
         <td align="center"><input type="text"  disabled=true name="Penh3" id="penh3"  size="20"></td></td>
     </tr>
     <tr bgcolor="#FFCCCC"><td height="42"><strong>Measles 1st Dose, JE 1st Dose(After 9 months)</strong></td>
        <td align="center"><input type="text"  disabled=true name="meas" id="meas"  size="20"></td>
        <td align="center"><input type="text"  disabled=true name="meash" id="meash"  size="20"></td>
     </tr>
</form>
</table>
</body>
</html>
Posted

Hi, you may check this link to change your datetime variable to a specific string format
http://www.csharp-examples.net/string-format-datetime/[^]
 
Share this answer
 
C#
string formatedDate = DateTime.Now.ToString("dd/MM/yyyy");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900