18 EventsValidation
18 EventsValidation
CS380
Page/window events
2
name description
load the browser loads the page
unload the browser exits the page
resize the browser window is resized
the user right-clicks to pop up a
contextmenu
context menu
an error occurs when loading a
error
document or an image
CS380
Page/window events
3
CS380
Form events
4
$("id")["name"] JS
CS380
Prototype and forms
6
CS380
Client-side validation code
7
string.match(regex)
ifstring fits the pattern, returns the matching text; else
returns null
can be used as a Boolean truthy/falsey test:
CS380
Replacing text with regular
9
expressions
string.replace(regex, "text")
replaces the first occurrence of given pattern with the
given text
var str = “Xenia Mountrouidou";
str.replace(/[a-z]+/, "x") returns " Xxnia
Mountrouidou"
returns the modified string as its result; must be stored
str = str.replace(/[a-z]/, "x")
CS380
Key event objects
12