Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,390 --> 00:00:03,860
In this lecture, we're going to validate the password fields.
2
00:00:04,110 --> 00:00:05,890
We have two of them in our form.
3
00:00:06,150 --> 00:00:08,870
The second field is to verify the password.
4
00:00:09,210 --> 00:00:12,480
We want to check that the user is sure about their password.
5
00:00:13,050 --> 00:00:16,560
VALIDATE has a rule for checking if two fields match.
6
00:00:16,750 --> 00:00:19,000
We'll learn about what that rule is in a moment.
7
00:00:19,260 --> 00:00:23,820
First, we'll focus on preparing the fields under the age field.
8
00:00:23,830 --> 00:00:29,340
You'll find the password field will change the input field to the field component.
9
00:00:31,860 --> 00:00:34,650
We'll set the name attribute to password.
10
00:00:37,210 --> 00:00:43,540
Next, we'll begin adding the rules in these schema object, we'll use the following rules for the password
11
00:00:43,540 --> 00:00:46,570
field required minimum, maximum.
12
00:00:50,360 --> 00:00:56,080
Throughout this section, you'll notice I've been setting a minimum and maximum cap for each input,
13
00:00:56,450 --> 00:00:59,420
this rule set isn't required but recommended.
14
00:00:59,780 --> 00:01:05,280
Most databases will usually come with a limit on how much data can be inserted into it.
15
00:01:05,690 --> 00:01:08,940
While it's not your responsibility to manage the database.
16
00:01:09,050 --> 00:01:12,110
It's always good to ask or check what the limits are.
17
00:01:12,530 --> 00:01:15,910
This will allow you to import those limits in your forms.
18
00:01:16,220 --> 00:01:19,670
The limits I'm using are ones I use in real applications.
19
00:01:19,970 --> 00:01:21,500
Feel free to follow along.
20
00:01:21,680 --> 00:01:27,340
Sometimes you may need to use different limits, increase or decrease the limits as you see fit.
21
00:01:27,950 --> 00:01:30,490
The next step is to work on outputting the error.
22
00:01:30,680 --> 00:01:33,800
We'll use the same markup for the other input fields.
23
00:01:34,010 --> 00:01:40,180
Scroll back to the password field copy and paste the markup for the error message from any other inputs
24
00:01:40,190 --> 00:01:43,820
we've already validated pasted below the password field.
25
00:01:46,390 --> 00:01:49,900
The name property will need to be updated to password.
26
00:01:52,250 --> 00:01:59,240
We can work on the next input, same process as before the confirmed password field can be found directly
27
00:01:59,240 --> 00:02:00,880
below the password field.
28
00:02:01,250 --> 00:02:07,250
We'll do the same thing we did to the other components, change the input element to the field component.
29
00:02:09,759 --> 00:02:13,150
Will sent the name attribute to confirm password.
30
00:02:15,610 --> 00:02:21,400
Up next, we need to add the rules, we're not going to use the same rules we used for the password
31
00:02:21,400 --> 00:02:24,770
field, it's not necessary to apply the same rules.
32
00:02:25,150 --> 00:02:30,700
The purpose of the confirmation password field is to double check that the user correctly inputted their
33
00:02:30,700 --> 00:02:31,310
password.
34
00:02:31,660 --> 00:02:37,430
The rule will want to use should check if the input matches the input in the password field.
35
00:02:37,750 --> 00:02:43,030
This can seem a little tricky, but luckily we validate comes with an easy to use solution.
36
00:02:43,360 --> 00:02:50,230
First, we'll need to import and register the rule, open the validation file, import a rule called
37
00:02:50,230 --> 00:02:51,070
confirms.
38
00:02:53,530 --> 00:02:59,830
In the Insull method for the plug in will add the confirmed rule with the defined rule function.
39
00:03:02,380 --> 00:03:08,610
The confirmed rule will check if the value inside the current input matches a value in another input,
40
00:03:08,890 --> 00:03:10,230
let's learn how to use it.
41
00:03:10,450 --> 00:03:13,430
Switch back to the authentication component file.
42
00:03:13,720 --> 00:03:16,630
Let's go to these schema object in our data function.
43
00:03:19,110 --> 00:03:23,280
Will aren't the confirmed rule to the confirmed password field?
44
00:03:25,800 --> 00:03:31,530
The confirmed rule requires you pass in the name of the field, the current input should match against
45
00:03:31,830 --> 00:03:34,620
will set this rule to at password.
46
00:03:37,260 --> 00:03:43,020
The value must correspond to the name we assigned to the field component with the value we're checking
47
00:03:43,020 --> 00:03:45,890
against the at symbol is required.
48
00:03:46,080 --> 00:03:49,560
It'll tell validate to search for a field with this name.
49
00:03:49,950 --> 00:03:55,290
This rule will tell validate to search for a field component with the name password.
50
00:03:57,850 --> 00:04:02,260
The last thing we'll need to do is at the ER, let's scroll back up to the template.
51
00:04:02,590 --> 00:04:06,580
We'll copy the error message component from one of the previous fields.
52
00:04:09,180 --> 00:04:12,810
Then we'll paste it below the confirmed password field.
53
00:04:15,290 --> 00:04:18,350
We'll change the expression to password confirm.
54
00:04:20,060 --> 00:04:20,910
We're finished.
55
00:04:20,959 --> 00:04:22,760
Let's open the form in the browser.
56
00:04:25,270 --> 00:04:31,360
We'll input some values for both fields, if both password's don't match, we should see an error telling
57
00:04:31,360 --> 00:04:32,590
us that they don't match.
58
00:04:35,010 --> 00:04:40,350
Will receive an error from the validate, if we were to make the passwords match, then the error will
59
00:04:40,350 --> 00:04:40,940
go away.
60
00:04:43,530 --> 00:04:50,430
Great, we're finished with the name Email Age and Password Fields, we were able to cover some additional
61
00:04:50,430 --> 00:04:51,000
rules.
62
00:04:51,240 --> 00:04:55,320
A lot of the rules we covered can be reviewed by visiting the documentation.
63
00:04:55,680 --> 00:04:58,220
We've still got a few more fields to validate.
64
00:04:58,500 --> 00:05:01,110
Let's finish this up in the next couple of lectures.
6455
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.