Building Data-Driven Web Apps with Flask and SQLAlchemy Transcripts
Chapter: Client and server-side validation
Lecture: Concept: Client-side validation with HTML5

Login or purchase this course to watch this video and the rest of the course contents.
0:00 We saw that we can add client side validation and make the user experience a lot better. The browser will, in real time, without putting extra
0:09 load or effort on our server help the user get the data mostly right. And in order to do that we can just do a couple simple things.
0:17 We can add the required attribute and we can also set different types. So here we're setting the email type to be actually email rather than text.
0:27 And that will tell the browser, when it's required that hey, it should validate this stuff. Some of the late for the password we can say it's required
0:34 we have the numerical one as well and we can set a min value and a max value and so on. So it's super easy to just leverage HTML5 form values
0:43 or attributes, things like required in different types of input to make most of the validation happen
0:49 before you ever see any form of submit for the form. If they go and try to submit this without actually putting in an email address
0:58 it'll say, hey it looks like you typed something but it's not an email address an email address has an @ in it and so on.
1:05 So would you please create a proper email address maybe you thought was a username or your real name or whatever.
1:11 Just remember this in it of itself is not enough people could skip this in so many ways. So you got to do the same validation on the server
1:20 it's why the view models are such a thing of beauty but this definitely makes the experience for the users nicer.


Talk Python's Mastodon Michael Kennedy's Mastodon