Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda