Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Jul 2009
    Posts
    1
    Member #
    19525
    Cannot get it to validate, for leaps years, and feb,april 31.
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    </head>

    <?php
    $todo=$_POST['todo'];
    if(isset($todo) and $todo=="submit"){
    $month=$_POST['month'];
    $dt=$_POST['dt'];
    $year=$_POST['year'];
    $date_value="$month/$dt/$year";
    echo "mm/dd/yyyy format :$date_value<br>";
    $date_value="$year-$month-$dt";
    echo "YYYY-mm-dd format :$date_value<br>";
    }
    ?>

    <?php


    $m="2,4";
    $d="31";
    $y="";
    If(!checkdate($m,$d,$y)){
    echo "invalid date";
    }else {
    echo "Entry date is correct";
    }
    ?>


    <form method=post name=f1 action=''><input type=hidden name=todo value=submit>
    <table border="0" cellspacing="0" >
    <tr><td align=left >
    <select name=month value=''>Select Month
    <option value='01'>January</option>
    <option value='02'>February</option>
    <option value='03'>March</option>
    <option value='04'>April</option>
    <option value='05'>May</option>
    <option value='06'>June</option>
    <option value='07'>July</option>
    <option value='08'>August</option>
    <option value='09'>September</option>
    <option value='10'>October</option>
    <option value='11'>November</option>
    <option value='12'>December</option>
    </select>

    </td><td align=left >
    Date<select name=dt >
    <option value='01'>01</option>

    <option value='02'>02</option>
    <option value='03'>03</option>
    <option value='04'>04</option>
    <option value='05'>05</option>
    <option value='06'>06</option>
    <option value='07'>07</option>
    <option value='08'>08</option>
    <option value='09'>09</option>
    <option value='10'>10</option>
    <option value='11'>11</option>
    <option value='12'>12</option>
    <option value='13'>13</option>
    <option value='14'>14</option>
    <option value='15'>15</option>
    <option value='16'>16</option>
    <option value='17'>17</option>
    <option value='18'>18</option>
    <option value='19'>19</option>
    <option value='20'>20</option>
    <option value='21'>21</option>
    <option value='22'>22</option>
    <option value='23'>23</option>
    <option value='24'>24</option>
    <option value='25'>25</option>
    <option value='26'>26</option>
    <option value='27'>27</option>
    <option value='28'>28</option>
    <option value='29'>29</option>
    <option value='30'>30</option>
    <option value='31'>31</option>
    </select>


    <tr><td align=left >
    <select name=year value=''>Select Year
    <option value='2009'>2009</option>
    <option value='2010'>2010</option>
    <option value='2011'>2011</option>
    <option value='2012'>2012</option>
    <option value='2013'>2013</option>
    <option value='2014'>2014</option>
    <option value='2015'>2015</option>
    <option value='2016'>2016</option>
    <option value='2017'>2017</option>
    <option value='2018'>2018</option>
    <option value='2019'>2019</option>
    <option value='2020'>2020</option>
    </select>

    <input type=submit value=Submit>
    </table>


    </form>



    </html>

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,693
    Member #
    5580
    Liked
    717 times
    What is the purpose of the part in red?

    $m="2,4";
    $d="31";
    $y="";

    If(!checkdate($m,$d,$y)){
    echo "invalid date";
    }else {
    echo "Entry date is correct";
    }

    You can't use a month called "2,4"
    and you need to provide a year.



Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:13 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com