-
Notifications
You must be signed in to change notification settings - Fork 0
/
strings.html
42 lines (33 loc) · 1.13 KB
/
strings.html
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
<!DOCTYPE html>
<html lang="en">
<!-- philip white -->
<!-- cs102 assignment for strings -->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Input Example</title>
<script>
// code for input
// user input boxes
function ReturnUserInfo(){
var fullname = document.getElementById("fname").value + document.getElementById("lname").value;
var lengthofname = fullname.length;
if (lengthofname > 10){
document.getElementById("nameofperson").innerHTML = "The length of your name is: " + lengthofname;
}
else{
document.getElementById("nameofperson").innerHTML = "Your name is less than 10 characters";
}
//alert(fullname);
}
</script>
</head>
<body>
<label for="fname">First Name</label>
<input type="text" id="fname" placeholder="Enter first name here" /><br /><br />
<label for="lname">Last Name</label>
<input type="text" id="lname" placeholder="Enter last name here" /><br /><br />
<p id="nameofperson"></p><br /><br />
<button id="returnName" onclick="ReturnUserInfo()">Click here to return your name</button>
</body>
</html>