-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjQuery_for_forms.html
More file actions
33 lines (32 loc) · 1.13 KB
/
jQuery_for_forms.html
File metadata and controls
33 lines (32 loc) · 1.13 KB
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
<!DOCTYPE html>
<html>
<head>
<title>jQuery for Forms</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
<script type="text/javascript">
//return false doesn't allow the page to refresh
//.submit works in two ways 1.listner 2. used to hard submit
//.serialize preps forms being handled by a computer
$(document).ready( function(){
// alert('hello');
$('#form1').submit(function(){
// alert('you are submitting me');
console.log($(this).serialize());
return false
});
$('.btn').click(function(){
$('#form1').submit();
})
});
</script>
</head>
<body>
<form id="form1" action="process.php" method="post">
First name<input type="text" name="first_name"></input>
Last name<input type="text" name="last_name"></input>
Email<input type="text" name="email"></input>
<input type="submit" value="submit">
</form>
<button class="btn">Click me to use .submit() differently!</button>
</body>
</html>