-
Notifications
You must be signed in to change notification settings - Fork 0
/
09_guessingGame.html
66 lines (54 loc) · 1.79 KB
/
09_guessingGame.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Guess game</title>
<style>
body{
font-family: sans-serif;
margin: 20px;
padding-left: 10px;
}
</style>
</head>
<body>
<h1>Form Validation</h1>
<form>
<!-- <p>Enter number between 1 to 10</p> -->
Name: <input type="text" id="inputValue">
<br>
<br>
email: <input type="email" id="emailId"/>
<br>
<input type="submit" id="submitButton">
</form>
<script>
// let computerGenereatedNumber=Math.floor(Math.random()*10+1)
// let count = 1;
// console.log(computerGenereatedNumber)
document.getElementById("submitButton").onclick=function(){
let name = document.getElementById("inputValue").value
console.log(name)
if(name.trim()===''){
alert("you entered empty value")
}
let email=document.getElementById("emailId").value
if(!email.includes('@')) {
alert('please enter valid email address')
}
// if(userGeneratedNumber== computerGenereatedNumber){
// alert(`Congratulations!! You guessed the number right in ${count} guess`)
// }
// else if(userGeneratedNumber<computerGenereatedNumber){
// count++;
// alert(`you entered less value! pleas try using greater value`)
// }
// else{
// count++;
// alert(`you entered greater value! pleas try using less value`)
// }
}
</script>
</body>
</html>