Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/11/2014, 09:34
saikoru
 
Fecha de Ingreso: octubre-2014
Ubicación: Oaxaca
Mensajes: 11
Antigüedad: 9 años, 6 meses
Puntos: 0
Pregunta Evitar uso de fechas anteriores

Muy buen día amigos, algún tip que me puedan dar para evitar elegir fechas anteriores en un calendario, esto debido a que estoy realizando un sistema que permita poder cargar menús de comida al día, pero para evitar que por error elijan una fecha anterior quiero evitar con una validación que al elegir una fecha anterior a la fecha actual, el sistema le notifique al usuario que eligio erroneamente el dato.

El código que estoy ocupando es el siguiente:

Código PHP:
Ver original
  1. <?php
  2.     require_once("../scripts/verificar.php");
  3.     $js = "
  4.     <link rel=\"stylesheet\" href=\"../scripts/jquery.ui.all.css\" type=\"text/css\">
  5.     <script type=\"text/javascript\" src=\"../scripts/jquery.ui.core.js\"></script>
  6.     <script type=\"text/javascript\" src=\"../scripts/jquery.ui.widget.js\"></script>
  7.     <script type=\"text/javascript\" src=\"../scripts/jquery.ui.datepicker.js\"></script>";
  8.     _header("..::Nuevo Menu::..",menuUs(),$nombre,$js);
  9.     $fecha = date("Y-m-d");
  10. ?>
  11. <div class='form' style='width: 500px;'>
  12.             <h1>Nuevo Menú</h1>
  13.             <form id='form1' name='form1' method='post' action='nuevoMenu.php'>
  14.                 <ul>
  15.                 <li>
  16.                   <label>Fecha:</label><input autocomplete='off'  name='fecha' type='text'  class='validate[required,custom[date]]' id='fecha' value="<?php echo $fecha; ?>"></li>
  17.                 <li>
  18.                   <label>Hora de inicio:</label><input name='hi' type='text' value="<?php echo date("H:i"); ?>"  class='validate[required,custom[time]]' id='hi'></li>
  19.                  <li>
  20.                    <label>Hora Fin:</label><input class='validate[required,custom[time]]' type='text'  name='hf' placeholder="FIN DE SERVICIO" id='hf'></li>
  21.                  <li>
  22.                    <label>Platillo:</label>
  23.                    <select name="platillo" class="validate[required]" id="platillo">
  24.                     <?php
  25.                         $sql = "select idP,descripcion from platillo where estadoP = 1 order by descripcion;";
  26.                         $c = consulta($sql);
  27.                         if(num_fila($c) > 0){
  28.                             while($r = objetos($c))
  29.                                 echo "<option value='$r->idP'>$r->descripcion</option>";
  30.                            
  31.                         }
  32.                     ?>
  33.                    </select>
  34.                  </li>
  35.                  <li><input type='submit' value="Guardar" name='b1' id='b1'></li>
  36.                 </ul>
  37. </form>
  38.         </div><br />
  39. <?php
  40.     $sql = "select * from configuracion";
  41.     $conf = objetos(consulta($sql));
  42.     if(!empty($_POST)){
  43.         $post = slashes($_POST);
  44.         $f = $post["fecha"];
  45.         $hi = $post["hi"];
  46.         $hf = $post["hf"];
  47.         $p = $post["platillo"];
  48.        
  49.         $sql = "select * from menu where fecha ='$f'";
  50.         $c = consulta($sql);
  51.         if(num_fila($c) < 1){
  52.             $sql = "insert menu values('$f','$hi','$hf','$conf->costo','$conf->descuento','1');";
  53.             if(consulta($sql)){
  54.                 $sql = "insert menu_detalle values('$f','$p')";
  55.                 if(consulta($sql))
  56.                     echo href("addPlatillo.php?f=$f&&b=ok");
  57.                 else
  58.                     echo href("addPlatillo.php?f=$f&&b=error");
  59.             }
  60.         }else
  61.             echo msj(array("El menu de esta fecha ya se encuentra registrado"));
  62.  
  63.     }
  64.    
  65.     @$b = $_GET["b"];
  66.     if($b == 2) echo msj(array("Error al ejecutar la consulta"));
  67.     if($b == 1) echo msj(array("La insercion se realizo con exito"),"ok");
  68.  
  69.     echo "<script>
  70.         $(function() {
  71.             $( \"#fecha\" ).datepicker({
  72.              autoSize: true,
  73.                 dayNames: ['Domingo', 'Lunes', 'Martes', 'Mi�rcoles', 'Jueves', 'Viernes', 'S�bado'],
  74.                 dayNamesMin: ['Dom', 'Lu', 'Ma', 'Mi', 'Je', 'Vi', 'Sa'],
  75.                 firstDay: 1,
  76.                 monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
  77.                 monthNamesShort: ['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
  78.                 dateFormat: 'yy-mm-dd',
  79.                 changeMonth: true,
  80.                 changeYear: true,
  81.                 yearRange: \"-40:+10\",
  82.                
  83.            
  84.             });
  85.         });
  86.         </script>";
  87.     _footer();
  88. ?>

De antemano muchas gracias por su apoyo.