Skip to main content
se añadieron 261 caracteres en el cuerpo
Origen Enlace
CRIS19N
  • 425
  • 6
  • 24

Código completo con los FORM

<form  id="form1">id="form1" enctype="multipart/form-data">
    <input name="placa" type="text" id="placa" onkeyup="form1.placa.value=form1.placa.value.toUpperCase()" size="8" maxlength="7" style="font-size:25px;">
   
   </form>
<script>
const input = document.querySelector('input');
const value = document.getElementById("placa").addEventListener("keypress",value;

var expresion1 =/[A-Za-z]/;

var expresion2 = /[A-Za-z0-9]/;

input.onkeyup = logKey;

function logKey(e) {
 
    if (this.value.length<3 && /[A-Za-z]/value.testmatch(e.keyexpresion1)==true) {
        this.value+=evalue+=value.keyvalue.toUpperCase();
    } 

    if (this.value.length>=4 && /[A-Za-z0-9]/value.testmatch(e.keyexpresion2)==true) {
        return;
    }
    if (this.value.length==3) {
        this.value+="-";
    }
    e.preventDefault();
}); 


</script>

Código completo con los FORM

<form  id="form1">
    <input name="placa" type="text" id="placa" onkeyup="form1.placa.value=form1.placa.value.toUpperCase()" size="8" maxlength="7" style="font-size:25px;">
   
   </form>
<script>
document.getElementById("placa").addEventListener("keypress", function(e) {
    if (this.value.length<3 && /[A-Za-z]/.test(e.key)) {
        this.value+=e.key.toUpperCase();
    }
    if (this.value.length>=4 && /[A-Za-z0-9]/.test(e.key)) {
        return;
    }
    if (this.value.length==3) {
        this.value+="-";
    }
    e.preventDefault();
});
</script>

Código completo con los FORM

<form  id="form1" enctype="multipart/form-data">
    <input name="placa" type="text" id="placa" onkeyup="form1.placa.value=form1.placa.value.toUpperCase()" size="8" maxlength="7" style="font-size:25px;">
   
   </form>
<script>
const input = document.querySelector('input');
const value = document.getElementById("placa").value;

var expresion1 =/[A-Za-z]/;

var expresion2 = /[A-Za-z0-9]/;

input.onkeyup = logKey;

function logKey(e) {
 
    if (this.value.length<3 && value.match(expresion1)==true) {
        this.value+=value.value.toUpperCase();
    } 

    if (this.value.length>=4 && value.match(expresion2)==true) {
        return;
    }
    if (this.value.length==3) {
        this.value+="-";
    }
    e.preventDefault();
} 


</script>

Código completo con los FORM

<form  id="form1" enctype="multipart/form-data">id="form1">
    <input name="placa" type="text" id="placa" onkeyup="form1.placa.value=form1.placa.value.toUpperCase()" size="8" maxlength="7" style="font-size:25px;">
   
   </form>
<script>
document.getElementById("placa").addEventListener("keypress", function(e) {
    if (this.value.length<3 && /[A-Za-z]/.test(e.key)) {
        this.value+=e.key.toUpperCase();
    }
    if (this.value.length>=4 && /[A-Za-z0-9]/.test(e.key)) {
        return;
    }
    if (this.value.length==3) {
        this.value+="-";
    }
    e.preventDefault();
});
</script>

Código completo con los FORM

<form  id="form1" enctype="multipart/form-data">
    <input name="placa" type="text" id="placa" onkeyup="form1.placa.value=form1.placa.value.toUpperCase()" size="8" maxlength="7" style="font-size:25px;">
   
   </form>
<script>
document.getElementById("placa").addEventListener("keypress", function(e) {
    if (this.value.length<3 && /[A-Za-z]/.test(e.key)) {
        this.value+=e.key.toUpperCase();
    }
    if (this.value.length>=4 && /[A-Za-z0-9]/.test(e.key)) {
        return;
    }
    if (this.value.length==3) {
        this.value+="-";
    }
    e.preventDefault();
});
</script>

Código completo con los FORM

<form  id="form1">
    <input name="placa" type="text" id="placa" onkeyup="form1.placa.value=form1.placa.value.toUpperCase()" size="8" maxlength="7" style="font-size:25px;">
   
   </form>
<script>
document.getElementById("placa").addEventListener("keypress", function(e) {
    if (this.value.length<3 && /[A-Za-z]/.test(e.key)) {
        this.value+=e.key.toUpperCase();
    }
    if (this.value.length>=4 && /[A-Za-z0-9]/.test(e.key)) {
        return;
    }
    if (this.value.length==3) {
        this.value+="-";
    }
    e.preventDefault();
});
</script>

Código completo con los FORM

<form  id="form1" enctype="multipart/form-data">
    <input name="placa" type="text" id="placa" onkeyup="form1.placa.value=form1.placa.value.toUpperCase()" size="8" maxlength="7" style="font-size:25px;">
   
   </form>
<script>
document.getElementById("placa").addEventListener("keypress", function(e) {
    if (this.value.length<3 && /[A-Za-z]/.test(e.key)) {
        this.value+=e.key.toUpperCase();
    }
    if (this.value.length>=4 && /[A-Za-z0-9]/.test(e.key)) {
        return;
    }
    if (this.value.length==3) {
        this.value+="-";
    }
    e.preventDefault();
});
</script>

<form  id="form1" enctype="multipart/form-data">
    <input name="placa" type="text" id="placa" onkeyup="form1.placa.value=form1.placa.value.toUpperCase()" size="8" maxlength="7" style="font-size:25px;">
   
   </form>
<script>
document.getElementById("placa").addEventListener("keypress", function(e) {
    if (this.value.length<3 && /[A-Za-z]/.test(e.key)) {
        this.value+=e.key.toUpperCase();
    }
    if (this.value.length>=4 && /[A-Za-z0-9]/.test(e.key)) {
        return;
    }
    if (this.value.length==3) {
        this.value+="-";
    }
    e.preventDefault();
});
</script>

Código completo con los FORM

<form  id="form1" enctype="multipart/form-data">
    <input name="placa" type="text" id="placa" onkeyup="form1.placa.value=form1.placa.value.toUpperCase()" size="8" maxlength="7" style="font-size:25px;">
   
   </form>
<script>
document.getElementById("placa").addEventListener("keypress", function(e) {
    if (this.value.length<3 && /[A-Za-z]/.test(e.key)) {
        this.value+=e.key.toUpperCase();
    }
    if (this.value.length>=4 && /[A-Za-z0-9]/.test(e.key)) {
        return;
    }
    if (this.value.length==3) {
        this.value+="-";
    }
    e.preventDefault();
});
</script>

Origen Enlace
CRIS19N
  • 425
  • 6
  • 24
Loading