-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormFieldsExample02.htm
executable file
·38 lines (32 loc) · 1.22 KB
/
FormFieldsExample02.htm
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
<!DOCTYPE html>
<html>
<head>
<title>Form Fields Example</title>
<script type="text/javascript" src="EventUtil.js"></script>
</head>
<body>
<form method="post" action="javascript:alert('Form submitted!')" id="myForm">
<ul>
<li><input type="radio" name="color" value="red">Red</li>
<li><input type="radio" name="color" value="green">Green</li>
<li><input type="radio" name="color" value="blue">Blue</li>
</ul>
<input type="submit" value="Submit Form" name="submit-btn">
<button type="button">Whatever</button>
</form>
<script type="text/javascript">
(function(){
var form = document.forms[0];
//Code to prevent multiple form submissions
EventUtil.addHandler(form, "submit", function(event){
event = EventUtil.getEvent(event);
var target = EventUtil.getTarget(event);
//get the submit button
var btn = target.elements["submit-btn"];
//disable it
btn.disabled = true;
});
})();
</script>
</body>
</html>