1
00:00:00,510 --> 00:00:03,610
So far we've worked with h t AML and CSX.

2
00:00:03,690 --> 00:00:09,150
We know that both these programming languages instruct our web browser on how our web page should be

3
00:00:09,150 --> 00:00:10,470
displayed.

4
00:00:10,470 --> 00:00:18,740
We also learned that HDL and CSX are static languages that do not interact with users.

5
00:00:18,780 --> 00:00:24,930
In this section of the course we'll be exploring a very powerful client side programming language known

6
00:00:24,930 --> 00:00:26,260
as javascript.

7
00:00:26,580 --> 00:00:32,730
When we say client side it means the language communicates with our web browser to allow user to web

8
00:00:32,730 --> 00:00:40,080
page interactivity client side languages differ from server side languages such as BHP which will cover

9
00:00:40,080 --> 00:00:47,340
later on server side languages communicate not with the web browser but with a web server.

10
00:00:47,340 --> 00:00:53,390
JavaScript can be used to implement many different types of interactive features on a web page.

11
00:00:54,960 --> 00:00:59,220
Let's take a look at some examples of JavaScript functions that interact with users

12
00:01:07,530 --> 00:01:19,690
this javascript code calculates the amount of characters a user has typed into a text area.

13
00:01:20,700 --> 00:01:26,340
Once you type in the line of text and press to calculate characters button you'll see that this line

14
00:01:26,340 --> 00:01:29,130
of text has twenty three characters

15
00:01:36,110 --> 00:01:38,800
this javascript code displays an error message.

16
00:01:38,820 --> 00:01:41,820
If more than 10 words were typed into a text area

17
00:01:50,730 --> 00:01:54,900
this is the pop up alert that appears if more than 10 words are typed in

18
00:02:01,790 --> 00:02:06,890
this javascript code validates a form to make sure that the required fields were completed.

19
00:02:20,920 --> 00:02:29,870
I purposely put an incorrect email address and left the other fields blank these fields are required.

20
00:02:29,870 --> 00:02:35,480
So once we click submit we receive an error message saying that some of the required fields were not

21
00:02:35,480 --> 00:02:36,590
completed.

22
00:02:36,590 --> 00:02:43,540
This is done using JavaScript validation will score much more advanced validation techniques than this.

23
00:02:43,550 --> 00:02:45,110
This is just a basic example

24
00:02:50,580 --> 00:02:56,700
this javascript code ensures a user agrees to the terms and conditions of a web page in order to submit

25
00:02:56,730 --> 00:02:57,330
a form

26
00:03:01,110 --> 00:03:06,000
if I do not check off this checkbox here.

27
00:03:06,000 --> 00:03:10,920
You'll notice I get a pop up message saying that we must check the box to continue.

28
00:03:11,070 --> 00:03:19,360
And again this is another javascript function.

29
00:03:19,380 --> 00:03:21,330
This is a slightly more advanced script.

30
00:03:21,330 --> 00:03:30,990
It's a tic tac toe game and the purpose is to line up the x's or O's all in one straight line diagonally

31
00:03:31,320 --> 00:03:32,700
horizontal your vertically

32
00:03:35,680 --> 00:03:42,840
and so you can see if you lose a pop up message appears indicating that the game is over and you've

33
00:03:42,840 --> 00:03:48,030
lost.

34
00:03:48,210 --> 00:03:51,650
These are just a few basic examples of what JavaScript can be used for.

35
00:03:58,100 --> 00:04:00,910
Javascript does have some limitations.

36
00:04:00,980 --> 00:04:06,670
We've already touched on one in that it cannot be used to communicate with the web server.

37
00:04:06,740 --> 00:04:10,940
Javascript cannot be forced onto a user's web browser either.

38
00:04:10,940 --> 00:04:16,910
Remember javascript is a client side language meaning if your user has turned off javascript support

39
00:04:16,940 --> 00:04:21,650
in their web browser your script will not work.

40
00:04:21,650 --> 00:04:28,610
Also if the user's web browser is outdated it may not allow certain JavaScript functions to work correctly.

41
00:04:28,640 --> 00:04:36,030
Note that almost all modern web browsers support javascript by default when installed.

42
00:04:36,110 --> 00:04:39,950
Many people also confuse javascript with Java.

43
00:04:39,950 --> 00:04:43,890
Note that these are two languages and they are not the same.

44
00:04:43,910 --> 00:04:51,740
Java is a much more powerful and complex language in the same category is C and C++

45
00:04:56,230 --> 00:04:58,960
javascript is an object oriented language.

46
00:04:58,960 --> 00:05:05,900
This means that attributes of an object are contained within variables.

47
00:05:05,960 --> 00:05:12,980
For example if we want to describe a person will refer to this person as the object we would typically

48
00:05:12,980 --> 00:05:19,080
use attributes such as name height weight gender and age.

49
00:05:19,430 --> 00:05:24,780
The values of these attributes will vary or differ from person to person.

50
00:05:24,860 --> 00:05:27,760
Another word for attributes is variables.

51
00:05:28,010 --> 00:05:34,870
These variables will contain the values for each person as we progressed through this dissection.

52
00:05:34,900 --> 00:05:40,030
You'll gain a better understanding of this concept and the importance of working with variables.
