Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,240 --> 00:00:06,390
In this lecture, we're going to talk about validation triggers, the validates can be configured to
2
00:00:06,390 --> 00:00:09,000
validate an input on different events.
3
00:00:09,270 --> 00:00:14,380
If we want, we can go with an aggressive validation tactic for validating inputs.
4
00:00:14,670 --> 00:00:20,070
First, let's understand the default behavior as to when an input is validated.
5
00:00:20,640 --> 00:00:24,140
Validation is performed on one of four occasions.
6
00:00:24,390 --> 00:00:29,490
If the input field emits the change event, validation will be performs.
7
00:00:29,760 --> 00:00:34,880
The change event is emitted whenever an alteration is made to the elements value.
8
00:00:35,490 --> 00:00:40,160
The second occasion is when value changes internally via JavaScript.
9
00:00:40,470 --> 00:00:44,010
It's possible to add the model directive to an input.
10
00:00:44,370 --> 00:00:50,760
If we decide to add the the model directive validate, we'll watch for changes on the property we have
11
00:00:50,760 --> 00:00:51,960
bound to the input.
12
00:00:52,350 --> 00:00:55,980
If a change occurs internally, validation will be triggered.
13
00:00:56,490 --> 00:00:59,790
The third occasion is when the blurr event is emitted.
14
00:01:00,060 --> 00:01:04,530
The blur and change events can sometimes occur at similar times.
15
00:01:04,890 --> 00:01:08,160
The difference between them is the Blur event is fired.
16
00:01:08,160 --> 00:01:10,710
When the user touches an input and moves away.
17
00:01:11,190 --> 00:01:13,590
It doesn't matter if they changed the input.
18
00:01:13,830 --> 00:01:17,030
As long as it was touched, the event will be emitted.
19
00:01:17,730 --> 00:01:22,410
The last occasion is when the form is submitted, all fields will be validated.
20
00:01:22,680 --> 00:01:26,630
Validate allows us to change when an input is validated.
21
00:01:27,000 --> 00:01:29,640
We don't have to stick with the default strategy.
22
00:01:31,670 --> 00:01:36,290
We are going to be working in the validation file, open it in your editor.
23
00:01:38,780 --> 00:01:44,810
We can change the validation trigger on all fields by updating the object we passed into the configure
24
00:01:44,810 --> 00:01:45,390
function.
25
00:01:45,830 --> 00:01:49,530
There are four options we can set to change the default behavior.
26
00:01:49,850 --> 00:01:54,030
Let's run through them one by one at the end of the object.
27
00:01:54,080 --> 00:01:57,500
We're going to add a property called Validate on blurr.
28
00:01:57,860 --> 00:01:59,390
Its value will be true.
29
00:02:02,040 --> 00:02:09,360
They validate on blurr option will tell validate if it should validate a field on the blurr event by
30
00:02:09,360 --> 00:02:11,640
default, this option is set to true.
31
00:02:11,970 --> 00:02:15,150
You can set it to false for a less aggressive behavior.
32
00:02:15,840 --> 00:02:19,470
The next property will add is called validate on change.
33
00:02:19,620 --> 00:02:21,270
Its value will be true.
34
00:02:24,010 --> 00:02:30,640
They validate unchanged option will tell the validate if it should validate a field on the change event,
35
00:02:31,030 --> 00:02:32,920
the default value is true.
36
00:02:33,530 --> 00:02:37,180
Afterward, we have the validate on input option.
37
00:02:37,600 --> 00:02:39,220
We will set this to false.
38
00:02:41,870 --> 00:02:48,140
This option is probably the most aggressive validation trigger, the input event is fired whenever the
39
00:02:48,140 --> 00:02:55,310
input changes, it's different from the change event because it'll fire on every keystroke the moment
40
00:02:55,310 --> 00:03:00,950
the user presses a key if the value is invalid and error will appear immediately.
41
00:03:01,400 --> 00:03:07,430
This option may be appropriate for inputs like passwords, but it's excessive for most input's.
42
00:03:07,730 --> 00:03:11,190
Users don't like to have errors thrown at them immediately.
43
00:03:11,540 --> 00:03:15,180
It's better if we wait until they have finished filling out the field.
44
00:03:15,630 --> 00:03:17,210
However, that's my opinion.
45
00:03:17,540 --> 00:03:19,070
Feel free to turn this on.
46
00:03:19,340 --> 00:03:21,970
The default value for this option is false.
47
00:03:22,550 --> 00:03:26,840
The last validation trigger is called validate on model update.
48
00:03:27,170 --> 00:03:28,880
The default value is true.
49
00:03:31,460 --> 00:03:37,940
This option will tell validate to validate the input whenever the value changes internally through the
50
00:03:37,940 --> 00:03:43,630
fee model directive, a total of four options to change the validation triggers.
51
00:03:43,970 --> 00:03:49,460
We are using the default values because I think the default behavior works fine for our case.
52
00:03:49,850 --> 00:03:52,910
I wanted to show you these options in case you need to change.
53
00:03:52,910 --> 00:03:57,950
The default behavior in the next lecture will continue working on validation.
5318
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.