Este artículo describe el método para obtener y verificar la fecha de inicio y finalización de JS. Compártelo para su referencia, como sigue:
function Validation () {var startDate = document.getElementById ("start_tenancydate_s"). valor; var endDate = document.getElementById ("end_tenancydate_s"). valor; var datesent = fatediff (endDate, startDate); if (startDate == "") {alerta ("alerta!"); falso;} if (endDate == "") {alert ("¡Seleccione la fecha de finalización!"); return false;} if (fatatesent> 365) {alerta ("La diferencia de fecha seleccionada excede el valor máximo de 1 año"); return false;} if (fechatesent <0) {alert (" verdadero;}} // Llame a este método (método principal) función fatediff (date1, date2) {var type1 = typeof date1, type2 = typeOf date2; if (type1 == 'string') date1 = stringTotime (date1); else if (date1.gettime) date1 = date1.gettime (); if (type2 == 'string') date2 = stringTotime (date2); else if (date2.gettime) date2 = date2.gettime (); return (date1 - date2)/(1000 * 60 * 60 * 24); // excepto 1000 es milisegundos, no se agrega segundo} // el método requerido para convertir un stringTotime (string) {var f = string.split ('', 2); var d = (f [0]? F [0]: '') .split ('-', 3); var t = (f [1]? F [1]: '') .split (':', 3); return (nueva fecha (parseInt (d [0], 10) || null, (parseInt (d [1], 10) || 1) -1, parseint (d [2], 10) || null, parseint (t [0], 10) || null, parseint (t [1], 10) || null, parseint (t [2], 10) || null)).For more information about JavaScript related content, please check out the topics of this site: "Summary of JavaScript Time and Date Operation Skills", "Summary of JavaScript Switching Effects and Skills", "Summary of JavaScript Search Algorithm Skills", "Summary of JavaScript Animation Special Effects and Skills", "Summary of JavaScript Errors and Debugging Skills", "Summary of JavaScript Data Structures and Algorithm Habilidades "," Resumen del algoritmo y habilidades de traversal JavaScript "y" Resumen del uso de la operación matemática de JavaScript "
Espero que este artículo sea útil para la programación de JavaScript de todos.