Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
In this section, we're going to focus on form validation.
Form validation is the process of checking if the input from the user is in the correct format.
For example, you may have a field for an age.
You can use validation to check if the input meets a set of criteria, you'll want to check if the value
is numeric.
It's also common to check if the number is between a minimum and maximum range.
Validation plays a role in saving resources.
Traditionally, form validation is performed on the server.
After a user fills out a form, the data is transmitted to a server before the server inserts the form
data into the database, it will validate the input.
In addition, the server may sanitize the data to prevent malicious code from executing.
Performing validation on user submitted data is a crucial step to take.
You don't want to insert improper data into the database.
There is a downside for performing validation on the server.
If the user makes a mistake, they'll have to wait for a response from the server to notify them of
their mistake.
In this day and age, most users have the expectation of immediate feedback.
On top of this, servers must allocate resources to process the request.
Performing validation on the server is costly and slow.
JavaScript has come a long way.
It's possible to perform form validation on the client.
It allows for a feedback to be immediate.
Since validation is performed on the browser, you save a lot on resources to be clear.
Validation should always be performed on the server regardless if we do it on the client, it may seem
redundant.
However, the purpose of form validation on the client is to improve user experience and save resources.
It is still possible to bypass validation if the user is smart enough.
In fact, form validation was one of the reasons why JavaScript was introduced as a language.
One of the original purposes of JavaScript was to perform form validation.
The user would receive immediate feedback.
If they made a mistake, the server wouldn't have to allocate resources since a request was never made
in the first place.
Even though the internet is faster than ever and servers are more powerful than before, it's still
a good idea to perform form validation.
It reduces the number of requests made to a server.
In the end, it's up to you.
Performing client signed form validation is optional.
All right, if you're convinced, then let's take a look at how we can perform form validation in view
by default view has minimal support for validation.
Technically, we can perform validation without a library or third party package.
The process is straightforward.
Events are used to listen for form submissions and user input before a form is submitted.
Conditions are performed against the user's input.
An error will get outputted.
If a condition fails, it's perfectly fine to use view on its own for form validation.
However, there is a problem you may need to perform validation on multiple forms.
This increases the likelihood of repetitive code.
In this instance, you may want to create a few functions that will help you manage some of the more
common and basic validation checks.
You could create this on your own, or you could use a third party library for this course.
We'll be using a third party library.
Another benefit of using a third party library is that they're usually tested to work on all browsers
and or kept up to date.
View doesn't provide any official libraries for form validation.
Instead, it recommends two options which are View LYDGATE and V validate.
In the resource section of this lecture, I provide a link to both libraries.
Both are excellent libraries.
Choosing one boils down to preference for this course we'll be using V validate.
It's more frequently updated and it's very flexible.
Let's begin the installation.
Switch over to the command line.
If you have the server running, turn it off.
Packages must be installed while the server isn't running.
After doing so, run the following command and pm i v validate.
We've successfully installed.
The library will continue in the next lecture.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.