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

157
Visualizações
Validation of characters in a text field

i am new at programming and my I think my question is easy, but I don't have any ideas. How to check if the number of characters in a text field matches 11? I tried this but I don't think that's a good lead.

<form name="formz">
         <input type='text' name='numbere' id="p"  maxlength="11">  
</form> 

<button onclick="writee()">x</button>
        <script>
function writee(){


    win=window.open(" ","tab","width=300,height=350")
      win.document.open()



 var l = document.forms["formz"].numbere;
 if(l.length==11){
    win.document.write( "under 11 characters <br/>");
 }else{
    win.document.write( " 11 characters <br/>");
 }
}
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Add minLength="11" to the same input.

Note that if you need more secure validation, you will also have to check the values on the server side. The Html attributes will only work for client-side validation. This means that someone who is determined to circumvent the length requirements could edit the source code in their browser and bypass your restrictions. For more casual use cases that are not security sensitive, the HTML attributes should suffice.

about 4 years ago · Juan Pablo Isaza Relatório

0

In terms of HTML please have a look at the input's attributes: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input

In JavaScript it has been answered here: Form Validation Vanilla JS

To further your knowledge about Regex validation, here are some examples: https://regex101.com/library?orderBy=RELEVANCE&page=1&search=validation

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