WEBVTT 00:00:05.890 --> 00:00:12.290 In this video we're going to learn a little bit more about alerts boxes. 00:00:12.600 --> 00:00:21.320 So we are now familiar with the symbol of that message using the window dog alerts method. 00:00:21.360 --> 00:00:26.850 So for example Welcome to our page 00:00:29.670 --> 00:00:36.220 can be shown in an alerts message when the page loads OK. 00:00:36.690 --> 00:00:44.350 Now we will see that there are other examples of using alerts boxes. 00:00:44.730 --> 00:00:55.380 So for instance we can set a variable to a boolean based on whether the user confirms something or not 00:00:55.390 --> 00:00:55.870 . 00:00:56.340 --> 00:01:03.800 So let's say we want to set a variable called accepts cookies. 00:01:03.940 --> 00:01:07.020 So except cookies. 00:01:07.280 --> 00:01:13.720 And basically we want to set this to true if the user accepts cookies and to false. 00:01:13.740 --> 00:01:16.650 If they if they don't. 00:01:16.770 --> 00:01:23.680 So the way we're going to do that is by setting this to a window does confirm. 00:01:24.890 --> 00:01:25.780 OK. 00:01:26.300 --> 00:01:33.250 And basically what's going to happen is the message is right here is going to appear on the screen. 00:01:33.420 --> 00:01:38.470 And then the user will confirm whether they want accepts cookies or not. 00:01:39.030 --> 00:01:48.540 So let's try something here so please confirm you accepts cookies. 00:01:48.730 --> 00:02:00.180 OK let's have an alert message right after that to show what the value of accepts cookies is. 00:02:03.480 --> 00:02:04.820 OK so let's see. 00:02:05.240 --> 00:02:11.940 So now you can see the message and he's promising us always asking us to confirm we accepts cookies 00:02:11.940 --> 00:02:20.340 so if we say OK so the value of accepts cookies is going to be true so let's reload the page now and 00:02:20.550 --> 00:02:23.300 rather than accepting we going to click Cancel. 00:02:23.300 --> 00:02:25.850 And now the value is false. 00:02:25.860 --> 00:02:26.780 OK. 00:02:27.690 --> 00:02:29.330 So we can do something here. 00:02:29.340 --> 00:02:39.120 So rather than having window alerts right opposite us we can use conditions and say if accepts cookies 00:02:40.170 --> 00:02:44.040 is equal to true then 00:02:46.650 --> 00:02:51.540 send an alert message saying you confirmed 00:02:55.070 --> 00:02:56.400 you accept cookies 00:02:59.560 --> 00:03:02.100 ok and else 00:03:09.830 --> 00:03:15.410 you send that alert message saying you 00:03:19.160 --> 00:03:23.780 you do not accept the keys. 00:03:24.690 --> 00:03:27.660 Let's try this is reload the page. 00:03:27.710 --> 00:03:34.530 So if we say OK so the message is going to be you can fairly accepts cookies and free refresh and we 00:03:34.860 --> 00:03:36.630 don't accept. 00:03:37.790 --> 00:03:42.990 OK so let's refresh the page because so 00:03:47.680 --> 00:03:49.740 OK. 00:03:50.430 --> 00:03:51.750 So we forgot something here. 00:03:51.750 --> 00:03:55.950 So we use an equal sign which we are setting the value of access cookies. 00:03:55.950 --> 00:03:56.830 True. 00:03:57.450 --> 00:03:59.910 The comparison is not stuff like that. 00:03:59.910 --> 00:04:02.710 We need two equal sides. 00:04:03.030 --> 00:04:03.680 OK. 00:04:03.900 --> 00:04:06.330 To compare. 00:04:06.330 --> 00:04:12.180 So please confirm you accept cookies if we say OK OK we get this message because the value is going 00:04:12.180 --> 00:04:16.570 to be true this time if we don't accept you do not accept cookies. 00:04:16.680 --> 00:04:18.050 OK. 00:04:18.060 --> 00:04:27.760 All right so now we're going to see another type of alert box boxes we going to see those boxes. 00:04:27.760 --> 00:04:34.240 Does will require the user to input some input. 00:04:34.380 --> 00:04:37.920 So it could be some text could be nabĂ» whatever. 00:04:38.240 --> 00:04:42.050 OK so the syntax is pretty easy. 00:04:42.300 --> 00:04:45.770 So we are declaring a variable. 00:04:46.370 --> 00:04:50.800 So let's say a variable is going to be visa. 00:04:51.090 --> 00:04:52.050 OK. 00:04:52.170 --> 00:05:00.510 And basically we can get a store in this variable whatever the user is going to put in our message. 00:05:00.570 --> 00:05:08.730 So the function of we need to use here is prompts and then we write the message that we want to show 00:05:09.270 --> 00:05:11.080 the alerts box. 00:05:11.130 --> 00:05:16.580 So please enter your name. 00:05:18.960 --> 00:05:26.290 OK so let's see what we get. 00:05:26.310 --> 00:05:34.830 So now please answer your name and whatever we put there is going to be actually stored in this variable 00:05:34.830 --> 00:05:35.610 . 00:05:35.610 --> 00:05:37.750 All right. 00:05:39.210 --> 00:05:42.800 So let's see. 00:05:44.490 --> 00:05:47.560 Let's send another message right after that after that. 00:05:47.580 --> 00:05:52.920 Using this this variable he's going to say hi 00:05:56.020 --> 00:06:00.820 and again to those the variable. 00:06:00.840 --> 00:06:03.000 So we need to 00:06:06.270 --> 00:06:10.620 say we wish you my experience 00:06:13.940 --> 00:06:23.300 page and don't forget to Like us on Facebook. 00:06:25.830 --> 00:06:26.100 OK 00:06:29.010 --> 00:06:33.170 . 00:06:33.570 --> 00:06:34.660 OK so destroy now 00:06:34.750 --> 00:06:40.400 . 00:06:40.760 --> 00:06:50.700 Now you can see that we are using the value of the data in the alerts that message if you want to make 00:06:50.700 --> 00:06:57.310 sure that's the name is shown in capital letters we can just use the two uppercase method. 00:06:58.110 --> 00:07:00.420 OK. 00:07:01.970 --> 00:07:06.910 Now we can see. 00:07:09.970 --> 00:07:10.710 OK. 00:07:11.160 --> 00:07:19.450 So this is not the best code we can use because if the user doesn't write anything in the prompt message 00:07:19.550 --> 00:07:21.320 this is going to be blank. 00:07:21.450 --> 00:07:26.850 So there are other ways actually of checking whether they have input something that validates their 00:07:26.850 --> 00:07:27.480 inputs. 00:07:27.690 --> 00:07:33.750 But for now are going to keep it simple as we are only learning how alert boxes work will be