Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,300 --> 00:00:06,510
In this lecture, we're going to focus on validating the email, the process is the same as before as
2
00:00:06,510 --> 00:00:07,470
an exercise.
3
00:00:07,470 --> 00:00:09,540
Try validating the email field.
4
00:00:09,780 --> 00:00:11,430
Be sure to output a message.
5
00:00:11,430 --> 00:00:17,660
If there's an error below the input field, refer to the documentation for the list of rules available.
6
00:00:17,970 --> 00:00:20,940
Don't feel pressure to use as many rules as you can.
7
00:00:21,240 --> 00:00:23,570
Keep it simple and use what you think is right.
8
00:00:23,910 --> 00:00:25,680
Pause the video and good luck.
9
00:00:27,360 --> 00:00:28,140
Welcome back.
10
00:00:28,320 --> 00:00:31,930
If you are able to validate the email field, then congrats.
11
00:00:31,980 --> 00:00:33,750
If not, that's fine as well.
12
00:00:33,990 --> 00:00:40,350
Let's go over it together, open the authentication component, file in the template, search for the
13
00:00:40,350 --> 00:00:41,250
email field.
14
00:00:43,500 --> 00:00:49,800
The first step is to convert the input into the field component will change the input element to the
15
00:00:50,110 --> 00:00:51,170
field component.
16
00:00:53,550 --> 00:01:00,570
The field component will output an input element next will give the input a name, will set the name
17
00:01:00,570 --> 00:01:01,380
to email.
18
00:01:03,820 --> 00:01:09,950
Afterward, we'll give the input some rules or using a validation schema to list our rules.
19
00:01:10,270 --> 00:01:17,740
Scroll down to the schema object in the data function, the rules will be the following required minimum
20
00:01:17,740 --> 00:01:21,790
set, two, three, maximum set to one hundred email.
21
00:01:24,310 --> 00:01:30,970
Or using the same rules we use for the name field, except for the Alpha Space's rule, emails typically
22
00:01:30,970 --> 00:01:32,140
don't have spaces.
23
00:01:32,290 --> 00:01:35,790
You're not required to set these rules in any particular order.
24
00:01:36,070 --> 00:01:42,040
I prefer to set the required rule first because I think it's worth checking before any other rule.
25
00:01:42,550 --> 00:01:45,090
I'm introducing a new rule called email.
26
00:01:45,360 --> 00:01:51,460
It will check if the input is a valid email, however, will receive an error because we haven't registered
27
00:01:51,460 --> 00:01:51,660
it.
28
00:01:52,000 --> 00:01:53,590
Let's register it as a rule.
29
00:01:53,770 --> 00:01:55,600
Open the validation file.
30
00:01:58,190 --> 00:02:05,060
We won't have to create an email rule because we validate comes with one, we can import the email function
31
00:02:05,060 --> 00:02:07,580
from the Validate Rules package.
32
00:02:09,970 --> 00:02:16,960
And our install method we can call the defined function will set the name to email with the email function.
33
00:02:19,480 --> 00:02:25,360
After registering the rule, we can use it in our component, we've already listed it as a rule for
34
00:02:25,360 --> 00:02:31,660
the email field, we can move on to the final step, which is to output the error, switch back to the
35
00:02:31,660 --> 00:02:35,690
authentication component file below the field component.
36
00:02:35,800 --> 00:02:38,440
We're going to add the error message component.
37
00:02:44,240 --> 00:02:49,040
We'll add the text, read six hundred class to change the text, color to read.
38
00:02:51,230 --> 00:02:55,040
Lastly, will set the name property to email.
39
00:02:57,830 --> 00:02:58,690
We're finished.
40
00:02:58,730 --> 00:03:01,660
Let's switch over to the browser to test if it works.
41
00:03:04,060 --> 00:03:10,230
Check the console for any errors, there shouldn't be any after confirming there are no errors, try
42
00:03:10,240 --> 00:03:12,550
and testing the registration email field.
43
00:03:15,040 --> 00:03:21,640
And air will appear if you try entering an invalid email, validate, considers an email valid if it
44
00:03:21,640 --> 00:03:25,250
has the at symbol with the domain extension at the end.
45
00:03:25,570 --> 00:03:31,510
If I were to input test at test dotcom, then that will result in a successful validation.
46
00:03:34,080 --> 00:03:36,880
We've successfully validated the email field.
47
00:03:37,110 --> 00:03:39,660
Let's move on to the other fields in the next one.
4593
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.