All language subtitles for 001 Setting up Form Validation_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French Download
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,180 --> 00:00:03,840 In this section, we're going to focus on form validation. 2 00:00:03,840 --> 00:00:09,600 Form validation is the process of checking if the input from the user is in the correct format. 3 00:00:09,630 --> 00:00:12,810 For example, you may have a field for an age. 4 00:00:12,810 --> 00:00:19,170 You can use validation to check if the input meets a set of criteria, you'll want to check if the value 5 00:00:19,170 --> 00:00:20,070 is numeric. 6 00:00:20,100 --> 00:00:24,990 It's also common to check if the number is between a minimum and maximum range. 7 00:00:25,290 --> 00:00:28,440 Validation plays a role in saving resources. 8 00:00:28,620 --> 00:00:32,759 Traditionally, form validation is performed on the server. 9 00:00:32,759 --> 00:00:39,720 After a user fills out a form, the data is transmitted to a server before the server inserts the form 10 00:00:39,720 --> 00:00:43,080 data into the database, it will validate the input. 11 00:00:43,080 --> 00:00:49,020 In addition, the server may sanitize the data to prevent malicious code from executing. 12 00:00:49,020 --> 00:00:53,700 Performing validation on user submitted data is a crucial step to take. 13 00:00:53,730 --> 00:00:57,540 You don't want to insert improper data into the database. 14 00:00:57,750 --> 00:01:01,440 There is a downside for performing validation on the server. 15 00:01:01,440 --> 00:01:06,930 If the user makes a mistake, they'll have to wait for a response from the server to notify them of 16 00:01:06,930 --> 00:01:07,800 their mistake. 17 00:01:07,830 --> 00:01:12,780 In this day and age, most users have the expectation of immediate feedback. 18 00:01:12,780 --> 00:01:17,850 On top of this, servers must allocate resources to process the request. 19 00:01:17,850 --> 00:01:21,540 Performing validation on the server is costly and slow. 20 00:01:21,870 --> 00:01:24,000 JavaScript has come a long way. 21 00:01:24,000 --> 00:01:27,750 It's possible to perform form validation on the client. 22 00:01:27,780 --> 00:01:30,270 It allows for a feedback to be immediate. 23 00:01:30,270 --> 00:01:36,630 Since validation is performed on the browser, you save a lot on resources to be clear. 24 00:01:36,630 --> 00:01:42,810 Validation should always be performed on the server regardless if we do it on the client, it may seem 25 00:01:42,810 --> 00:01:43,470 redundant. 26 00:01:43,470 --> 00:01:50,790 However, the purpose of form validation on the client is to improve user experience and save resources. 27 00:01:50,820 --> 00:01:55,500 It is still possible to bypass validation if the user is smart enough. 28 00:01:55,500 --> 00:02:01,380 In fact, form validation was one of the reasons why JavaScript was introduced as a language. 29 00:02:01,380 --> 00:02:06,540 One of the original purposes of JavaScript was to perform form validation. 30 00:02:06,570 --> 00:02:09,000 The user would receive immediate feedback. 31 00:02:09,000 --> 00:02:15,270 If they made a mistake, the server wouldn't have to allocate resources since a request was never made 32 00:02:15,270 --> 00:02:16,410 in the first place. 33 00:02:16,770 --> 00:02:22,230 Even though the internet is faster than ever and servers are more powerful than before, it's still 34 00:02:22,230 --> 00:02:24,960 a good idea to perform form validation. 35 00:02:24,960 --> 00:02:28,410 It reduces the number of requests made to a server. 36 00:02:28,410 --> 00:02:30,240 In the end, it's up to you. 37 00:02:30,240 --> 00:02:33,900 Performing client signed form validation is optional. 38 00:02:35,310 --> 00:02:41,370 All right, if you're convinced, then let's take a look at how we can perform form validation in view 39 00:02:41,370 --> 00:02:45,180 by default view has minimal support for validation. 40 00:02:45,240 --> 00:02:50,040 Technically, we can perform validation without a library or third party package. 41 00:02:50,070 --> 00:02:52,140 The process is straightforward. 42 00:02:52,170 --> 00:02:58,500 Events are used to listen for form submissions and user input before a form is submitted. 43 00:02:58,500 --> 00:03:01,860 Conditions are performed against the user's input. 44 00:03:01,860 --> 00:03:03,570 An error will get outputted. 45 00:03:03,570 --> 00:03:09,510 If a condition fails, it's perfectly fine to use view on its own for form validation. 46 00:03:09,510 --> 00:03:15,150 However, there is a problem you may need to perform validation on multiple forms. 47 00:03:15,150 --> 00:03:18,300 This increases the likelihood of repetitive code. 48 00:03:18,300 --> 00:03:23,670 In this instance, you may want to create a few functions that will help you manage some of the more 49 00:03:23,670 --> 00:03:26,070 common and basic validation checks. 50 00:03:26,070 --> 00:03:32,220 You could create this on your own, or you could use a third party library for this course. 51 00:03:32,220 --> 00:03:34,680 We'll be using a third party library. 52 00:03:34,680 --> 00:03:41,010 Another benefit of using a third party library is that they're usually tested to work on all browsers 53 00:03:41,010 --> 00:03:42,540 and or kept up to date. 54 00:03:42,570 --> 00:03:46,920 View doesn't provide any official libraries for form validation. 55 00:03:47,010 --> 00:03:53,130 Instead, it recommends two options which are View LYDGATE and V validate. 56 00:03:53,130 --> 00:03:57,710 In the resource section of this lecture, I provide a link to both libraries. 57 00:03:57,720 --> 00:03:59,730 Both are excellent libraries. 58 00:03:59,730 --> 00:04:05,190 Choosing one boils down to preference for this course we'll be using V validate. 59 00:04:05,190 --> 00:04:08,160 It's more frequently updated and it's very flexible. 60 00:04:08,160 --> 00:04:09,990 Let's begin the installation. 61 00:04:09,990 --> 00:04:11,700 Switch over to the command line. 62 00:04:11,700 --> 00:04:14,040 If you have the server running, turn it off. 63 00:04:14,040 --> 00:04:17,220 Packages must be installed while the server isn't running. 64 00:04:17,220 --> 00:04:22,860 After doing so, run the following command and pm i v validate. 65 00:04:25,320 --> 00:04:26,940 We've successfully installed. 66 00:04:26,940 --> 00:04:29,910 The library will continue in the next lecture. 6593

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.