-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
31 lines (31 loc) · 870 Bytes
/
app.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
require(['js/form'],function( form ){
function toggleText(evt) {
var tellUsText = document.getElementById("tell-us");
if (evt.target.value === "Others") {
tellUsText.disabled = false;
tellUsText.required = true;
tellUsText.focus();
}
else {
tellUsText.required = false;
tellUsText.disabled = true;
tellUsText.value = '';
}
}
/*****Add event handlers****/
( function() {
// Reset Button
var resetButton = document.getElementById("reset");
resetButton.onclick = form.resetForm;
// Radio button
var radios = document.getElementsByName("celeb-type");
var i=0;
while( i < radios.length ) {
radios[i].onchange = toggleText;
i++;
}
// Submit button
var submitForm = document.getElementById("cake-form");
submitForm.onsubmit = form.validateForm;
})();
});