/
OnSubmitExample2.htm
43 lines (38 loc) · 1.7 KB
/
OnSubmitExample2.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
39
40
41
42
43
<html>
<head>
<title>OnSubmit Example</title>
<!-- This example shows what happens when you try to use onsubmit
with a direct call to submit()...the form still submits! -->
<script type="text/javascript" src="eventutil.js"></script>
<script type="text/javascript">
function handleSubmit() {
var oEvent = EventUtil.getEvent();
oEvent.preventDefault();
}
</script>
</head>
<body>
<form id="form1" method="post" action="javascript:alert('Submitted')" onsubmit="handleSubmit()">
<!-- regular textbox -->
<label for="txtName">Name:</label><br />
<input type="text" id="txtName" name="txtName" /><br />
<!-- password textbox -->
<label for="txtPassword">Password:</label><br />
<input type="password" id="txtPassword" name="txtPassword" /><br />
<!-- age comboxbox (drop-down) -->
<label for="selAge">Age:</label><br />
<select name="selAge" id="selAge">
<option>18-21</option>
<option>22-25</option>
<option>26-29</option>
<option>30-35</option>
<option>Over 35</option>
</select><br />
<!-- multiline textbox -->
<label for="txtComments">Comments:</label><br />
<textarea rows="10" cols="50" id="txtComments" name="txtComments"></textarea><br />
<!-- custom submit button -->
<input type="button" value="Submit Form" onclick="document.forms[0].submit()" />
</form>
</body>
</html>