Presentation is loading. Please wait.

Presentation is loading. Please wait.

CIS 228 The Internet 12/6/11 Forms and Validation.

Similar presentations


Presentation on theme: "CIS 228 The Internet 12/6/11 Forms and Validation."— Presentation transcript:

1 CIS 228 The Internet 12/6/11 Forms and Validation

2 Associative Arrays Array - collection of variables with the same name differentiated by an index (key) Keys can be Strings as well as integers. var atomicNumber = new Array(); atomicNumber[“hydrogen”] = 1; atomicNumber[“carbon”] = 6; atomicNumber[“oxygen”] = 8; Var ratio = 64 / atomicNumber[“zinc”]; Form element maps field names to the fields myForm[“zipcode”] = “10468”;

3 innerHTML Property A property of XHTML elements function enterText(el) { Var in = prompt(“enter text”, “”); el.innerHTML = in; }... Enter your HTML text click here

4 Event Attributes onload when the page loads (in opening body tag) onclick when the mouse clicks on an element onfocus when the focus is on an element onblur when the focus leave an element onchange when focus leaves and the value changes

5 XHTML Forms Limited 2-way communication between user & server (Heretofore server supplies information to the user) Browser sends name-value pairs to server application Names are specified by the application Values are supplied by the user Application responds with new web page for browser (Creating server applications beyond this course) Forms structure the interaction Give user “natural” means of supplying information

6 Form Element action Relative (path to local application) Absolute (path to application on a different site) method post - form data bundled in separate communication Cannot be bookmarked get - form data appended to url Size limited Do not use to transmit sensitive data

7 XHTML Form Elements (groups form fields together) (caption for a field set)

8 Input Element Types text value (default), size, maxlength radio value (value), checked checkbox value (value), checked submit value (button text) reset value (button text) button value (button text) password value (default), size, maxlength file (value invalid), accept image value (value), src, alt hidden value (default)

9 Regular Expressions regular-expression character-set regular-expression regular-expression regular-expression “|” regular-expression regular-expression (“*” | “+” | “?” | “{” int (“,” int)? “}”) “(” regular-expression “)” character-set character (non metacharacter) metacharacter “[” “^”? (character (“-” character))*) “]”

10 Metacharacters. any character except newline \n newline \d any digit \w any letter or digit \s whitespace (space, tab, newline, etc.) \D \W \S (not a digit, not a leter or digit, not whitespace) ^ the beginning of a string $ the end of a string \\ \. \^ \$ \/ \| \* \+ \? \( \) \{ \} \[ \] (\. ^ $ / | * + ? ( ) { } [ ])

11 Regular Expression Examples Identifier: [a-zA-Z_$][a-zA-Z0-9_$]* Zipcode: \d\d\d\d\d, \d{5}, [0-9]{5} Date: \d\d\/\d\d\/(\d\d | \d\d\d\d) Time: 1?\d(:[0-5]\d)?((a|p)m)?


Download ppt "CIS 228 The Internet 12/6/11 Forms and Validation."

Similar presentations


Ads by Google