Saltar al contenido

Tipos de input en html

junio 12, 2022

Html form

<input>: The Input (Form Input) elementThe <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element is one of the most powerful and complex in all of HTML due to the sheer number of combinations of input types and attributes.<input> typesHow an <input> works varies considerably depending on the value of its type attribute, hence the different types are covered in their own separate reference pages. If this attribute is not specified, the default type adopted is text.

AttributesThe <input> element is so powerful because of its attributes; the type attribute, described with examples above, being the most important. Since every <input> element, regardless of type, is based on the HTMLInputElement interface, they technically share the exact same set of attributes. However, in reality, most attributes have an effect on only a specific subset of input types. In addition, the way some attributes impact an input depends on the input type, impacting different input types in different ways.

Input type=radio

Additional attributesIn addition to the attributes commonly supported by all <input> types, inputs of type number support these attributes.listThe values of the list attribute is the id of a <datalist> element located in the same document. The <datalist> provides a list of predefined values to suggest to the user for this input. Any values in the list that are not compatible with the type are not included in the suggested options. The values provided are suggestions, not requirements: users can select from this predefined list or provide a different value.maxThe maximum value to accept for this input. If the value entered into the element exceeds this, the element fails constraint validation. If the value of the max attribute isn’t a number, then the element has no maximum value.

This value must be greater than or equal to the value of the min attribute.minThe minimum value to accept for this input. If the value of the element is less than this, the element fails constraint validation. If a value is specified for min that isn’t a valid number, the input has no minimum value.

Radio button

In the previous article we looked at the <input> element, covering the original values of the type attribute available since the early days of HTML. Now we’ll look at the functionality of newer form controls in detail, including some new input types, which were added in HTML5 to allow collection of specific types of data.

Note: Most of the features discussed in this article have wide support across browsers. We’ll note any exceptions. If you want more detail on browser support, you should consult our HTML forms element reference, and in particular our extensive <input> types reference.

Because HTML form control appearance may be quite different from a designer’s specifications, web developers sometimes build their own custom form controls. We cover this in an advanced tutorial:  How to build custom form widgets.E-mail address fieldThis type of field is set using the value email for the type attribute:

When this type is used, the user is required to type a valid email address into the field. Any other content causes the browser to display an error when the form is submitted. You can see this in action in the below screenshot.

Tipo de entrada=archivo Validación de formularios del lado del cliente✔MDNForm_validationSupport en todos los motores actuales.Firefox4+Safari5+Chrome4+Opera≤12.1+Edge79+Edge (Legacy)12+Internet Explorer10+Firefox Android4+Safari iOS4+Chrome Android18+WebView Android≤37+Samsung Internet1.0+Opera Android≤12.1+

✔MDNHTMLFormElementSoporta todos los motores actuales.Firefox1+Safari3+Chrome1+Opera8+Edge79+Edge (Legacy)12+Internet Explorer5.5+Firefox Android4+Safari iOS1+Chrome Android18+WebView Android1+Samsung Internet1.0+Opera Android10. 1+Categorías:Contenido de flujo.Contenido palpable.Contextos en los que se puede utilizar este elemento:Donde se espera contenido de flujo.Modelo de contenido:Contenido de flujo, pero sin descendientes de elementos de formulario.Omisión de etiquetas en text/html:No se puede omitir ninguna etiqueta. Atributos de contenido:Atributos globalesaccept-charset – Codificación de caracteres a utilizar para el envío de formulariosaction – URL a utilizar para el envío de formulariosautocomplete – Configuración por defecto de la función de autorrelleno para los controles del formularioenctype – Tipo de codificación de la lista de entrada a utilizar para el envío de formulariosmethod – Variante a utilizar para el envío de formulariosname – Nombre del formulario a utilizar en el documento.forms APInovalidate – Saltar la validación del control del formulario para el envío de formulariostarget – Contexto de navegación para el envío de formulariosrelConsideraciones de accesibilidad:Para autores.Para implementadores.Interfaz DOM:

Esta web utiliza cookies propias para su correcto funcionamiento. Al hacer clic en el botón Aceptar, acepta el uso de estas tecnologías y el procesamiento de tus datos para estos propósitos. Más información