/ Published in: JavaScript

Descripción: Valida los campos de fechas que requieren ser comparados (una fecha posterior a la otra) enviados por la función validaForm-->http://snipplr.com/view/58245/funcin-validaform-para-validar-formularios-con-parmetros-xml-y-nombres-de-clase/. En el caso de que no sea validado, llama a la función errorOutputPre y envia el elemento como parámetro
Recibe: El elemento del fomulario.
Se complementa con: la funcion fechasValida2-->http://snipplr.com/view/58279/funcion-fechasValida2/
Recibe: El elemento del fomulario.
Se complementa con: la funcion fechasValida2-->http://snipplr.com/view/58279/funcion-fechasValida2/
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function fechasValida2(msgType){ if ((fechasInicio==undefined)||(fechasFinal==undefined)){ //Si alguna de la variables que usa, son undefined, se salta el siguiente bloque. } //Convierte las fechas introducidas en objetos Data y calcula cual es posterior. else{ var fecha1Array=fechasInicio.split("/"); var fecha2Array=fechasFinal.split("/"); var fecha1Date=new Date(fecha1Array[2],fecha1Array[1],fecha1Array[0]); var fecha2Date=new Date(fecha2Array[2],fecha2Array[1],fecha2Array[0]); var fecha1Milisecundos=fecha1Date.getTime(); var fecha2Milisecundos=fecha2Date.getTime(); if (fecha1Milisecundos<fecha2Milisecundos){ } else{ fechasInicio=undefined; fechasFinal=undefined errorOutputPre(element_form); } } }
Comments
