Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

144
Vistas
How can we create date of birth field using validation

How can we add validation in date of birth input field . I create one input field of date of birth and in this field it's show like that 01/07/1997. But I want to get when date of birth enter in field it's showing like that, Xx/xx/1997. Only year want to show date and months not show.

I tried but not work. Anyone please help me out to resolve this issue.

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try this and change the code as per your requirement changes- I have updated here you just copy paste this code into following URL-http://jsfiddle.net/h9f46/84/

  function validate(date){
    var eighteenYearsAgo = moment().subtract(18, "years");
    var birthday = moment(date);
    var dateVar = new Date(birthday);
    if (!birthday.isValid()) {
        return "invalid date";    
    }
    else if (eighteenYearsAgo.isAfter(birthday)) {
        return "**/**/"+ dateVar.getFullYear().toString(); 
    }
    else {
        return "sorry, no";    
    }
}

jsprint(validate, "12/10/2000");

enter image description here

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda