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

206
Vistas
Input numbers must be 6 digit numbers or 9 digits numbers

I want to make that input numbers are 6 digits or 9 digits numbers. No less than 6 digits, not between 6 and 9 digits and no more than 9 digits numbers. May I know how can I make that? Codes will be insert below

<label class="control-label col-sm-5" for="badgeid" style="margin-left: -50px;">ID:</label>;
            <div class="col-sm-4">;
            <p class="form-control-static" style="margin-top: -6px;">
    <input type="number" class="form-control" id="secuid" name="secuid" min="0" placeholder="Enter ID" value=" $return_id">
    <label class="control-label col-sm-6" style="color: red; font-size: 12px; margin-right: 20px;display: contents;">** 6 Digit ST Employee ID / 9 SecurityID **</label>
    </p>
            </div>
            <div class="col-sm-10"></div>

Below is Javascript.

var secuid = document.translot.secuid.value;
    if (secuid == null || secuid == ""){
        alert("Please Insert the ID.")
        return false;
    }
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Use the pattern attribute and this regex:

\b\d{6}\b|\b\d{9}\b
/* Start with a non-word character then 6 consecutive digits then 
another non-word character OR start with a non-word character then 
9 consecutive digits then another non-word character */

type="number" ignores pattern attribute believe it or not, so use type="tel"

In the example test it by observing the warning messages it gives as will as the invalid error message when attempting to send anything not within the criteria.

<form>
<input type='tel' pattern='\b\d{6}\b|\b\d{9}\b' required>
<button>TEST</button>
</form>

about 4 years ago · Juan Pablo Isaza Denunciar

0

It is pretty simple - use 'pattern' alongside maxlength.

Way 1:

<html>
<body>

<h1>The input pattern attribute</h1>

<form action="/action_page.php">
  <label for="secuid">Enter ID:</label>
  <input type="text" id="secuid" name="secuid" pattern="(\d{6}|\d{9})" maxlength="9" title="Enter ID"><br><br>
  <input type="submit">
</form>
  
</body>
</html>

See JSFiddle (1) here

Way 2 use minlength=6, maxlength=9, and allow for only numbers: pattern="[0-9]+

<input type="text" id="secuid" name="secuid" pattern="[0-9]+" minlength="6" maxlength="9" title="Enter ID">

See JSFiddle (2) here

Note: no javascript needed

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