JQuery - envio con alerta de dos condiciones

 
Vista:
Imágen de perfil de Francisco Javier
Val: 19
Ha mantenido su posición en JQuery (en relación al último mes)
Gráfica de JQuery

envio con alerta de dos condiciones

Publicado por Francisco Javier (8 intervenciones) el 14/10/2020 20:10:54
Buenas en el siguiente codigo lo que trato es de que en el formulario a la hora de enviar la reserva si elige la fecha en martes y la hora pasada las 16 horas salga un mensaje de alerta. Lo he intentado hacer con javasscript puro como vereis en el código comentando y por eso me he decido intentarlo por jquery. En la lines 152 esta el script de jquery pero no me termina de funcionar. llevo bastante tiempo con este problema y necesito que alguien me ayude.
Un saludo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<!DOCTYPE html>
 
<html lang="es">
<head>
    <meta charset="UTF-8">
    <title>reservas online</title>
    <link rel="stylesheet" href="css/reservas.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
 
 
</head>
<body>
        <h1>Haz tu Reserva</h1>
           <div id="idiomas">
<nav id="gr" onClick="viajeIn()"></nav>
 
<style>
#gr{
background-image:url("css/imagenescss/gr.jpg");
height:50px;
width:50px;
border:solid;
webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover;
}
 
</style>
 
 
 
 
<nav id="fr"onClick="viajeFr()"></nav>
 
<style>
#fr{
background-image:url("css/imagenescss/fr.jpg");
height:50px;
width:50px;
border:solid;
webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover;
}
</style>
 
 
 
 
 
<nav id="al"onClick="viajeAl()"></nav>
 
<style>
#al{
background-image:url("css/imagenescss/al.jpg");
height:50px;
width:50px;
border:solid;
webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover;
}
nav{
float:left;
margin-left:200px;
border:solid;
 
}
#al:hover,#gr:hover,#fr:hover{
height:55px;
width:55px;
color: lime;
opacity:0.6;
transition:0.9s;
}
</style>
 
 
 
 
</div>
           <br><br><br>
 
            <div id="wrapper" class="container">
 
          <form  id="formulario" name="causas" action="confirmar.php" method="post" enctype="multipart/form-data">
 
 
 
              <fieldset legend="datos de reserva">
                 <p> <label for="nombre">Nombre</label>
                 <input type="text" name="nombre" placeholder="nombre"required>
                <p> <label for="apellidos">Apellidos</label>
                 <input type="text" name="apellidos" placeholder="apellidos"required>
                <p> <label for="email">Email</label>
                <input type="email" name="email" placeholder="email"required>
               <p> <label for="telefono">Teléfono</label>
                <input type="tel" name="telefono" placeholder="teléfono"required>
               <p> <label for="horaComida">Comida</label>
                <input type="time" name="horaComida" max="16:00" min="13:00" "hora"required>
                <p> <label for="hora">Cena</label>
                <input type="time" name="hora" max="22:30" min="19:00" "hora"required>
               <p> <label for="comensales">Comensales</label>
                <input type="number" name="comensales" min="1" max="15"
    placeholder="px"   required><p> <label for="fecha">Fecha</label>
                <input type="date" name="fecha" placeholder="fecha"required><p style="color:red": >Los Domingos estamos cerrados<br>Los Martes por la noche estamos cerrados.</p> <br><br><br>
               <p> <label for="nota">Haz un comentario</label>
                <textarea  class="nota"type="text" row="5" cols="50"name="nota"     > </textarea>
                  <input type="submit" name="registrarse" value="ENVIAR">
                  <input type="reset" value="BORRAR">
 
                  <input type="checkbox" name="privacidad"required/>he leido y acepto la <a href="imagenes/CLAUSULA%20P%C3%81GINA%20WEB.pdf" target="_blank"> Politica de privacidad
 
 
 
 
                   </a> </fieldset>
 
 
 
 
 
          </form>
 
            </div>
 
 
 
  <script>
 
 
      document.querySelector("input[name=fecha]").addEventListener("change",function(){
            x=new Date(this.value);
           if (x.getDay()==0){
               alert("Cambie la fecha, los domingos estamos cerrados");
this.value="";
           }
  });
    </script>
          <script>
    /*document.querySelector("input[name=fecha]").addEventListener("change",function(){
            x=new Date(this.value);
           if (x.getDate()<=31 && x.getDate()>=15){
              alert("Cambie la fecha,esta semana estamos de vacaciones");
                           this.value="";
           }
 });*/
 
 
 
 
/*const fecha=new Date(document.querySelector("input[name=fecha]").value);
if (fecha.getDay()==2 && fecha.getHours()>=16) {
    alert("los martes por la noche estamos cerrados");
}*/
     $(document).ready(function(){ //funcion ready
       var dia=$(".fecha").value;
         var hora=$(".hora").value;
         $("#formulario").submit(function() //funcion envio
             if(dia.getDay()==2 && hora.getHours()>=16){  //funcion if
             alert("los martes por la noche estamos cerrados");
         } //cerramos funcion if
 
         }); //cerrampos funcion envio
       }); //cerramos funcion ready
    </script>
  <script>
 
 
function viajeIn(){
 
location.href="basereservasingles.html";
document.getElementById("gr").click();
}
 
 
 
function viajeFr(){
 
location.href="basereservasfrances.html";
document.getElementById("fr").click();
}
 
 
 
function viajeAl(){
 
location.href="basereservasalemania.html";
document.getElementById("al").click();
}
 
 
 
 
 
</script>
 
 
 
 
</body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder