18 EventsValidation
18 EventsValidation
CS380
Page/window events
2
CS380
Page/window events
3
CS380
Form events
4
window.observe("load", function() {
$("orderform").observe("submit", verify);
});
function verify(event) {
if ($("zipcode").value.length < 5) {
event.stop(); // cancel form submission
unless
} // zip code is 5 chars long
}
CS380 JS
Prototype and forms
5
$("id")["name"] JS
CS380
Prototype and forms
6
CS380
Client-side validation code
7
CS380
Key event objects
12