Skip to main content
se añadieron 27 caracteres en el cuerpo; título editado
Origen Enlace

Input required Atributo definido como false but in console issale como true [ The required of Schrödinger ]

I was trying to make a function with the proof that the input data congen withEstoy intentando crear una función en Javascript con la que comprobar los inputs con el atributo required en true.

The problem is that although specified that isEl problema es que aunque este especificado que es false, when the data is ael resultado que da es true Boolean.

Example codeCódigo de ejemplo:

var serial_no = document.getElementsByName('serial_no')[0];
console.log(serial_no);
console.log(serial_no.required);
<form>
    <input type="text" name="serial_no" placeholder="serial_no" value="" required="false">
</form>

Have any explanation¿Existe alguna solución?

The required of Schrödinger

Input required false but in console is true [ The required of Schrödinger ]

I was trying to make a function with the proof that the input data congen with required true.

The problem is that although specified that is false, when the data is a true Boolean.

Example code:

var serial_no = document.getElementsByName('serial_no')[0];
console.log(serial_no);
console.log(serial_no.required);
<form>
    <input type="text" name="serial_no" placeholder="serial_no" value="" required="false">
</form>

Have any explanation?

The required of Schrödinger

Atributo definido como false sale como true

Estoy intentando crear una función en Javascript con la que comprobar los inputs con el atributo required en true.

El problema es que aunque este especificado que es false, el resultado que da es true.

Código de ejemplo:

var serial_no = document.getElementsByName('serial_no')[0];
console.log(serial_no);
console.log(serial_no.required);
<form>
    <input type="text" name="serial_no" placeholder="serial_no" value="" required="false">
</form>

¿Existe alguna solución?

The required of Schrödinger

Origen Enlace

Input required false but in console is true [ The required of Schrödinger ]

I was trying to make a function with the proof that the input data congen with required true.

The problem is that although specified that is false, when the data is a true Boolean.

Example code:

var serial_no = document.getElementsByName('serial_no')[0];
console.log(serial_no);
console.log(serial_no.required);
<form>
    <input type="text" name="serial_no" placeholder="serial_no" value="" required="false">
</form>

Have any explanation?

The required of Schrödinger