• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Validate PopUp Calendar JavaScript

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! I have trouble validating a popup calendar, when i selected date in the calendar and put it in the field, it supose to go to validate the date isn't greater than today, but i have to click twice for do that. I am using event onBlur. I left part of code that i use. I hope someone can to help me!

function validate_f(fechaing){

var fecha = fechaing.value

var dia= fecha.split("/")[0];
var mes= fecha.split("/")[1];
var anio= fecha.split("/")[2];

var fechaactual = new Date();

var mesactual = parseInt(fechaactual.getMonth()) + 1;
var anioactual = fechaactual.getFullYear();
var diaactual = fechaactual.getDate();
if(dia>diaactual && mes==mesactual && anio==anioactual){
alert('La fecha es incorrecta');
}else{
if(dia>=diaactual && mes>mesactual && anio==anioactual){
alert('La fecha es incorrecta');
}else{
if(anio>anioactual){
alert('La fecha es incorrecta');
}
}
}
} //hasta aqui javascript

<!--html-->
<tr bgcolor="#A3BDE4">
<td>Fecha del ejercicio económico:</td>
<td>
<input name="txtFecha_inv" type="text" class="texto_fecha" id="txtFecha_inv" size="12" maxlength="12" onfocus="this.onblur()">
<a href="javascript:void(0)" onclick="if(self.gfPop)gfPop.fPopCalendar(inversion.txtFecha_inv);return false;" title="Seleccione Fecha" onblur="validate_f(inversion.txtFecha_inv);" HIDEFOCUS><img name="popcal" align="absmiddle" src="../../../imagenes/calendario.gif" border="0" alt="Seleccionar fecha"></a>
</td>
</tr>

 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read this UseCodeTags and edit your post.

Eric
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your calendar code has to tell you when the selection is made. It is going to be impossible for the onblur code to fire and tell you something happened since it will fire before the calendar will put the date into the field.

Eric
 
My pie came with a little toothpic holding up this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic