Expresiones Regulares Input HTML5

Las expresiones regulares son patrones utilizados para encontrar una determinada combinación de caracteres dentro de una cadena de texto.

El atributo pattern en HTML5: Expresiones regulares para la validación de inputs.

Sintaxis del atributo pattern HTML5

<input type="text" name="nombre" pattern="{4-16}">
<!-- El usuario solo podrá meter en el input de 4 a 16 caracteres entre las letras de A-Z y a-z -->

Compatibilidad del atributo pattern HTML5.
Este atributo es compatible con los siguientes input:
email
password
search
tel
text
url

A continuación una serie de pattern que te ayudaran a validar tus input.

  • Pattern para validar un input de cédula de identidad o extranjero, rif, pasaporte, gobierno, :
<input type="text" name="cedula" pattern="^([VEJPG]{1})([0-9]{7,9})$" />

El usuario solo podra introducir en el input una cédula o RIF o Pasaporte valido por ejemplo: V12345670 o E59345670 o J407401150 o P187401150 o G115222685″

 

  • Pattern numérico
    <input type="text" name="numero" pattern="[0-9]{11}" />

Solo podrán ingresar 11 caracteres  numéricos.

  • Pattern correo electrónico
    <input type="text" name="correo" pattern="[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+" />

El usuario solo podrá ingresar una dirección de correo valida ejemplo: prueba@dominio.com

Solo escribiremos el codigo pattern ya que explicamos anteriormente la Sintaxis.

  • Pattern dirección MAC
    pattern="[a-fA-F0-9.+_-]+:[a-fA-F0-9.+_-]+:[a-fA-F0-9.+_-]+:[a-fA-F0-9.+_-]+:[a-fA-F0-9.+_-]+:[a-fA-F0-9.+_-]+"

Solo admite hexadecimal y  el formato de entrada de datos es: 12:43:a3:5e:88:9b

 

  • Pattern Moneda
    pattern="^[0-9]{0,12}([,][0-9]{2,2})?$"

Ejemplo:

1200,50

1000

2342,98

 

  • Pattern ip
    pattern="\b([1-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\b"

Ejemplo: 192.153.33.63

  • Pattern ip:port
    pattern="[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:[0-9]{1,5}"

Ejemplo: 193.56.143.178:8080

  • Pattern Fecha de nacimiento
    pattern="(\d{4})"

    Ejemplo: 1990

  • Pattern Numero de teléfono
    pattern="[(]?\d{3}[)]?\s?-?\s?\d{3}\s?-?\s?\d{4}"

ejemplo: 4129409998 o (800)-555-2468

  • Pattern Numero de teléfono a nivel mundial
    pattern="^\s*(?:\+?(\d{1,3}))?([-. (]*(\d{3})[-. )]*)?((\d{3})[-. ]*(\d{2,4})(?:[-.x ]*(\d+))?)\s*$"

    Ejemplos: +584246573321
    +42 555.123.4567
    +1-(800)-123-4567
    +7 555 1234567
    +7(926)1234567
    (926) 1234567
    +79261234567

  • Pattern Numero mayor de  0
    pattern="[1-9]\d{0,}"
  • Pattern Contraseña
    pattern="(?=[#$-/:-?{-~!"^_`\[\]a-zA-Z]*([0-9#$-/:-?{-~!"^_`\[\]]))(?=[#$-/:-?{-~!"^_`\[\]a-zA-Z0-9]*[a-zA-Z])[#$-/:-?{-~!"^_`\[\]a-zA-Z0-9]{4,}"

Ejemplo:

1234f
1Password
password234D

  • Pattern Fecha
    pattern="(0[1-9]|[12][0-9]|3[01])[\/.](0[13578]|1[02])[\/.](20)[0-9]{2}|(0[1-9]|[12][0-9]|30)[\/.](0[469]|11)[\/.](20)[0-9]{2}|(0[1-9]|1[0-9]|2[0-8])[\/.](02)[\/.](20)[0-9]{2}|29[\/.](02)[\/.](((20)(04|08|[2468][048]|[13579][26]))|2000)"

Ejemplo: Formato DD.MM.YYY

Ejemplo:

01.01.2014
11.01.2014
21.01.2014
31.01.2014
28.02.2000
02.02.2000
12.09.2014

  • Pattern URL
    pattern="([--:\w?@%&+~#=]*\.[a-z]{2,4}\/{0,2})((?:[?&](?:\w+)=(?:\w+))+|[--:\w?@%&+~#=]+)?"

Ejemplo:

google.com

micarro.es

prueba.tk

www.demo.co.uk

www.conexiones-jl.com.ve/tienda

  • Pattern Tiempo
    pattern="([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?"

Ejemplo: Formato 24 Horas

21:50:00
14:40
23:10
9:33
19:30

  • Pattern Fecha y Hora
    pattern="((0[1-9]|1[0-2])\-(0[1-9]|1[0-9]|2[0-9]|3[01])\-\d{4})(\s+)(([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])|24:00:00)"

Formato: MM-DD-YYYY HH:MM:SS 24 Horas

Ejemplo:

01-01-2016 11:45:25
03-02-2016 11:45:25
05-10-2016 11:45:25
07-15-2016 11:45:25
09-20-2016 11:45:25
10-25-2016 11:45:25
11-30-2016 11:45:25
12-31-2016 24:00:00

  • Pattern Twitter Link y Hashtags
    pattern="([@][A-z]+)|([#][A-z]+)"

Ejemplo: @prueba #expresiones #regulares

  • Pattern Código Postal
    pattern="(^\d{5}([\-]?\d{4})?$)|(^(GIR|[A-Z]\d[A-Z\d]??|[A-Z]{2}\d[A-Z\d]??)[ ]??(\d[A-Z]{2})$)|(\b((?:0[1-46-9]\d{3})|(?:[1-357-9]\d{4})|(?:[4][0-24-9]\d{3})|(?:[6][013-9]\d{3}))\b)|(^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ])\ {0,1}(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$)|(^(F-)?((2[A|B])|[0-9]{2})[0-9]{3}$)|(^(V-|I-)?[0-9]{5}$)|(^(0[289][0-9]{2})|([1345689][0-9]{3})|(2[0-8][0-9]{2})|(290[0-9])|(291[0-4])|(7[0-4][0-9]{2})|(7[8-9][0-9]{2})$)|(^[1-9][0-9]{3}\s?([a-zA-Z]{2})?$)|(^([1-9]{2}|[0-9][1-9]|[1-9][0-9])[0-9]{3}$)|(^([D-d][K-k])?( |-)?[1-9]{1}[0-9]{3}$)|(^(s-|S-){0,1}[0-9]{3}\s?[0-9]{2}$)|(^[1-9]{1}[0-9]{3}$)|(^\d{6}$)"

Ejemplo:

2121

12125

  • Pattern Código de color Hex detector
    pattern="[#]([\dA-F]{6}|[\dA-F]{3})"

Ejemplo:

#23AFEF

#ffa

#23afef

  • Pattern Dirección Bitcoin (Monedero)
    pattern="([13][a-km-zA-HJ-NP-Z0-9]{26,33})"

Ejemplo:

3Nxwenay9Z8Lc9JBiywExpnEFiLp6Afp8v

3KBUuGko4H5ke7EVsq9B7PLK1c5Askdd7y

1KiVwxEuGBYavyKrxkLncJt2pQ5YUUQX7f

 


Aquí termina el post con algunas de las tantas expresiones regulares que se pueden crear para validar nuestros input en HTML5.

7 thoughts on “Expresiones Regulares Input HTML5

  • Doctors have many challenges to face as they are perennially surrounded by patients, diseases, hospital duties and over-extended or odd shift timings. Universally, doctor is considered to be a noble profession and respectable one at that, but a doctor also has to work under immense pressures, emotional strains and other physical challenges.

    A regular physician like most of us at some point face will have to deal with personal situations such as important family affairs, family holidays, sickness or pregnancy that may force them to abandon medical duties. At the same time, a hospital or a healthcare facility is also constantly faced with emergency situations that demand all hands on deck round-the-clock. Therefore, every hospital, clinic or nursing home is compelled to hire locum tenens or substitute doctor in order to keep the staffing under control at all times.

    In fact, locum doctors are the most valuable asset for the medical community because they provide quality medical care and act as a helping-hand in emergency situations when the medical facilities need them the most.

    Unlike regular or permanent doctors, locum doctor jobs are also ideal career options for medical interns and graduates because they offer a wide array of medical exposure in varied medical specialties, work cultures and healthcare systems. Locum jobs are challenging and flexible, thus an increasing number of medical professionals have benefitted from these jobs, so whether one is looking for a family physicians position or in a hospital or in a clinic, locum jobs for doctors are available at all levels and in different healthcare systems.

    In addition, being a locum doctor gives a medical professional the control over their working hours, location of work and choice of area of specialisation. Technically, locum positions are not restricted to general physicians but they are also extended to other fields of medical specialisations such as cardiology, neurology and many more.

    Travelling can be an integral part of locum jobs, and these distinctive features are a boon for many dedicated medical professionals who are eager to expand their medical careers with loads of multi-cultural medical experiences. The fact that locum agencies in the UK recruit tens of thousands of locums from across the globe in various NHS hospitals, private clinics, nursing homes and other public hospitals speaks volume of the popularity of locum jobs.

    Locating or getting a locum tenens job is a simple task as long as you are registered with one of the many reputable locum agencies. These agencies act as the middle man between locum tenens and medical facilities, and they also look after all the details pertaining to travel for locum tenens, accommodation and the nature of locum work.

    Thus, maintaining a healthy locum doctor-agency relationship benefits both the parties, and it also increases the probability of getting recommendable employment opportunities and businesses or vice-versa.

  • ome people, especially those running on busy daily schedules tend to use the pills to help maintain weight since they can not afford to follow all the diet programs. This is not advised. It is recommended that one seek advice from a professional in this field before using the pills. This can save one from many dangers associated with the misuse.

    The diet pills should always be taken whole. Some people tend to divide the pills to serve a longer period of time. This is not advised and can lead to ineffectiveness. If it is required that one takes a complete tablet, it means that a certain amount of the ingredients are required to achieve the desired goal. It is also recommended that one does not crush the pill and dissolve it in beverages. Chemicals found in beverages have the potential of neutralizing the desired nutrients in the pill thereby leading to ineffectiveness. The best way to take the tablets is swallowing them whole with a glass of water.

    https://www.cialissansordonnancefr24.com/cialis-suivi-de-commande/

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *