Тёмный

The HTML "pattern" Attribute - Regular Expressions on Input Fields! 

dcode
Подписаться 132 тыс.
Просмотров 42 тыс.
50% 1

In this video we take a look at the new "pattern" attribute in HTML which allows you to add custom validation to your input fields through the form of a regular expression pattern.
Support me on Patreon:
/ dcode - with enough funding I plan to develop a website of some sort with a new developer experience!
For your reference, check this out:
developer.mozilla.org/en-US/d...
Follow me on Twitter @dcode!
If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!

Опубликовано:

 

30 дек 2018

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 34   
@matthewguillen2823
@matthewguillen2823 2 года назад
Thanks so you’re a champ!!!! You’re videos are better than the ALL others!!!!
@Alfasapiens
@Alfasapiens 3 года назад
wow very simple but very important for forms fields you gave us a great explanation it helps me a bunch. thumbs up lol
@natqe4049
@natqe4049 5 лет назад
thanks man. you helped me a lot
@nisrog9762
@nisrog9762 3 года назад
thanks man that was really helpful
@examtoppers7541
@examtoppers7541 3 года назад
thanks man u saved my entire day
@MarcusVinicius-bo1oc
@MarcusVinicius-bo1oc 3 года назад
Thank you. Awesome video
@mahirdaiyansafwaan2148
@mahirdaiyansafwaan2148 5 лет назад
Awesome tutorial pls create a ajax crash course in one video
@saronabi1387
@saronabi1387 Год назад
very clear, thank you so much
@ulasfakir
@ulasfakir Год назад
helped a lot
@ofek15
@ofek15 5 лет назад
Nice video dom
@wcof8006
@wcof8006 2 года назад
Thank you😭😭🙏🙏..... you just solved my problem for me🤝🤝
@akshaysingh548
@akshaysingh548 3 года назад
Thanks for the explanation, I need this particular pattern but I'm unable to create it. I need a pattern for zip-code of length 6, to begin with, either V8B or V0N or V8E and last 3 can be anything but first should be any one of these only this is to limit the zip-code to a particular region
@cristhiancastillo2391
@cristhiancastillo2391 2 года назад
Thanks so much
@Sujhavana
@Sujhavana 2 года назад
thx for the video man
@-AbhishekMathpati
@-AbhishekMathpati 2 года назад
Thank you
@xxapoloxx
@xxapoloxx 7 месяцев назад
Is there a way to trigger the validation with out submiting?. say on loosing focus?.
@lifesfluff
@lifesfluff Год назад
thank you
@theancientvoice9272
@theancientvoice9272 5 лет назад
Thanks, that can be useful in some scenario, but I still prefer js script validation for more security
@dcode-software
@dcode-software 5 лет назад
If you're simply putting a pattern restriction on an input field I wouldn't say there's a difference between this and JS but of course the JS will give you more flexibility in general
@theancientvoice9272
@theancientvoice9272 5 лет назад
​@@dcode-software I agree, I guess that was the main goal of that attribute, but do you think it is the same in term of security? I mean using a JS framework VS a pattern attribute. I mean a DOM attribute is easy to bypass through the developer tools panel, whereas reading a validation script and amend it seems a way more demanding to me.
@dcode-software
@dcode-software 5 лет назад
In my opinion there's no difference when it comes to security because every aspect of the front-end can be manipulated by the user. What if they choose to use something like cURL instead to send the HTTP Request? No HTML or JS would come into play there
@kedarsatwik6938
@kedarsatwik6938 2 года назад
you are providing very useful content, could you please tell me how the pattern should be written for taking credit card number as input means i want 1234 space 1234 space like that
@nanlistudio
@nanlistudio 4 года назад
Hi mate..how to code a pattern validation for full-name like:(Maximum of 80 alpha characters in total. First character of each word must be capitalised. Allow for up to three words. Allow for names like O'Reilly or Lewis Roberts-Thomson )...thx
@shivanshsahu4908
@shivanshsahu4908 3 года назад
These conditions can be achieved using the following pattern Number Submit This will ensure that the name is capitalized properly and includes 2/3 words, First name and/or middle name and last name respectively Hope this helps!
@shivanshsahu4908
@shivanshsahu4908 3 года назад
Also I think I should explain the code to you because it looks really weird and unreadable, "[A-Z][a-z]*[\s][A-Z][a-z]*([\s][A-Z][a-z]*)?" The first term [A-Z] says that the first letter should be anything between capital A-Z The second one [a-z]* says that anything after the first letter should be between small a-z and the '*' symbol tells it to read the text until any other argument is released The [\s] term asks it to read a space This is followed by [A-Z][a-z]* which says that the first letter again should be capital followed by small characters. In the next term ([\s][A-Z][a-z]*)? the bracket surrounding the term and the ? at the end of it creates an optional statement, that will be allowed if required. In the brackets the first term is [\s] that asks it to read a space again, it will be only applied if the user is willing to type another word. The next term [A-Z][a-z]* says that the first letter again should be capital followed by small characters.
@input-pattern8688
@input-pattern8688 2 года назад
@@shivanshsahu4908 for single char "\s" there is no neet for square brackets . @Nan Li For Names like o'Relley or Roberts-Thomson you must include the characters in the square bracket.
@yousseftijdit
@yousseftijdit 5 лет назад
Maan thank you so much
@input-pattern8688
@input-pattern8688 2 года назад
[A-Za-z\d\.]+ => Dot with backslash before means input can have dots (.) without backslash dot means ALL characters.
@nagarajghadi3981
@nagarajghadi3981 5 лет назад
hii can you give demonstration on pattern that accept minimum value should greater than 10000 without using javascript
@shivanshsahu4908
@shivanshsahu4908 3 года назад
You can simply create it using this code Number Submit Whenever the user will type in a number less than 10000, the form will tell the user that the value must be equal to or greater than 10000. You can also add a maximum limit using the max attribute with the min attribute like so, Number Submit This will insist the user to type in a number between 10000 and 15000 Hope this helped!
@israelzinplaygames8065
@israelzinplaygames8065 2 года назад
What means the "." in the pattern ????
@input-pattern8688
@input-pattern8688 2 года назад
[A-Za-z\d\.]+ => Dot with backslash before means input can have dots (.) without backslash dot means ALL characters.
@navkang4
@navkang4 Год назад
anything
Далее
СПРАВКА ДЛЯ УНИВЕРА
00:44
Просмотров 206 тыс.
JavaScript Client-side Form Validation
29:07
Просмотров 709 тыс.
Learn Regular Expressions In 20 Minutes
20:52
Просмотров 1,2 млн