-
Notifications
You must be signed in to change notification settings - Fork 0
/
rb_formsubmit2.js
49 lines (36 loc) · 1.47 KB
/
rb_formsubmit2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
New Perspectives on HTML and CSS, 7th Edition
Tutorial 7
Review Assignment
Filename: rb_formsubmit2.js
Purpose: The purpose of this program is to verify that the form
passes an initial validation test.
When the form is submitted, the onsubmit event handler
verifies that the form data is complete and valid.
An alert box is displayed notifying the user.
The event function returns a value of false so that the
student does not have to continually retype test values
in the survey form.
For the customer form, the script also disables and enables
the delivery and pickup options so that only one set of
options is enabled at any one time.
*/
window.onload = init;
function init() {
document.forms[0].onsubmit = function () {
if (this.checkValidity()) alert("Data passes initial validation tests");
return false;
};
document.getElementById("delivery").onclick = turnOnDelivery;
document.getElementById("pickup").onclick = turnOnPickup;
}
function turnOnDelivery() {
document.getElementById("addressBox").disabled = false;
document.getElementById("delBox").disabled = false;
document.getElementById("pickupBox").disabled = true;
}
function turnOnPickup() {
document.getElementById("addressBox").disabled = true;
document.getElementById("delBox").disabled = true;
document.getElementById("pickupBox").disabled = false;
}