Server vs Clientside validation Java Script Java Script

  • Slides: 19
Download presentation
Server vs Client-side validation

Server vs Client-side validation

Java. Script • Java. Script is an object-based language. • Java. Script is based

Java. Script • Java. Script is an object-based language. • Java. Script is based on manipulating objects by modifying an object’s properties or by applying methods to an object. – objects are items that have a defined existence – each object has properties that describe its appearance, purpose, or behavior – each object has methods, which are actions that can be performed with the object or to it

variable vs object • Read pg. 8. 11 session 8. 2 on variables •

variable vs object • Read pg. 8. 11 session 8. 2 on variables • Read pgs. 9. 04 -9. 12 on objects: object names and properties

Java. Script Objects

Java. Script Objects

A Part of the Document Object Model window frame document button event history anchor

A Part of the Document Object Model window frame document button event history anchor checkbox document form input location image radio reset link navigator style select submit screen tag textarea

Working with Object Properties • Each object in Java. Script has properties associated with

Working with Object Properties • Each object in Java. Script has properties associated with it. • The number of properties depends on the particular object; some objects have only a few properties, while others have many. • As with object names, certain keywords identify properties.

Object and Properties

Object and Properties

Modifying a Property’s Value • The syntax for changing the value of a property

Modifying a Property’s Value • The syntax for changing the value of a property is: object. property = expression – object is the Java. Script name of the object you want to manipulate – property is a property of that object – expression is a Java. Script expression that assigns a value to the property

Setting an Object’s Property Value Java. Script commands document. fg. Color document. bg. Color

Setting an Object’s Property Value Java. Script commands document. fg. Color document. bg. Color window. default. Status resulting Web page

Assigning a Property to a Variable • Although you cannot change the value of

Assigning a Property to a Variable • Although you cannot change the value of read-only properties, you can assign a value to a variable in your Java. Script program. • The syntax for assigning a property to a variable is: variable = object. property – variable is the variable name – object is the name of the object – property is the name of its property

Using Property Values to Variables • A conditional statement changes how the Web page

Using Property Values to Variables • A conditional statement changes how the Web page behaves based on the value of an object property. • The following Java. Script code shows how you can incorporate object properties into a simple conditional expression: If (document. bg. Color==“black”) { document. fg. Color=“white”; } else { document. fg. Color=“black”; } • Using objects, properties, and conditional statement provides a great deal of control over the appearance of a Web page.

Working with Object Methods • Another way to control a Web page is to

Working with Object Methods • Another way to control a Web page is to use methods. • Methods are either actions that objects perform or actions applied to objects. • The syntax for applying a method to an object is: object. method(parameters); – object is the name of the object – method is the method to be applied – parameters are any values used in applying the method to the object

Java. Script Objects and Their Methods

Java. Script Objects and Their Methods

Managing Events • An event is a specific occurrence within the Web browser. For

Managing Events • An event is a specific occurrence within the Web browser. For example: – opening up a Web page – positioning the mouse pointer over a location on that page • Events are an important part of Java. Script programming, you can write scripts that run in response to the actions of the user, even after the Web page has been opened.

Working with Event Handlers • Events are controlled in Java. Script using event handlers

Working with Event Handlers • Events are controlled in Java. Script using event handlers that indicate what actions the browser takes in response to an event. • Event handlers are created as attributes added to the HTML tags in which the event is triggered. • The general syntax is: < tag onevent = “Java. Script commands; ”> – tag is the name of the HTML tag – onevent is the name of the event that occurs within the tag – Java. Script commands are the commands the browser runs in response to the event

Events Initiated by the User During Data Entry

Events Initiated by the User During Data Entry

A selection list object • Read pgs. 9. 25 -9. 28 • refer to

A selection list object • Read pgs. 9. 25 -9. 28 • refer to the function placeorder() in jackson. html • document. form_name. list_name. selected. Index • document. form_name. list_name. options[#]. text e. g. , document. order. Product. selected. Index document. order. Product. options[i]. text

A radio button object • Read pg. 9. 29 -9. 30 • document. form_name.

A radio button object • Read pg. 9. 29 -9. 30 • document. form_name. button_name[#]. length • document. form_name. button_name[#]. checked e. g. , document. order. USE[3]. checked

A check box object • Read pg. 9. 33 -9. 36 • document. form_name.

A check box object • Read pg. 9. 33 -9. 36 • document. form_name. button_name. checked e. g. , document. Registration. brkfst. checked