-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.js
56 lines (42 loc) · 1.63 KB
/
events.js
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
(function(){
var references = {};
references.bookname = document.getElementById("bookName");
references.bookid = document.getElementById("bookId");
references.bookauthor = document.getElementById("bookAuthor");
references.btnsubmit = document.getElementById("btnSubmit");
references.btnsubmit.addEventListener("click",display);
references.btnsubmit.addEventListener("mouseover",iteration);
references.bookid.addEventListener("keypress",addbookid);
references.bookname.addEventListener("keypress", addbookname);
references.bookauthor.addEventListener("keypress", addbookauthor);
function display(){
console.log("Submit button is clicked");
}
function iteration(){
console.log("Mouse pointing on the button");
}
function addbookid(myevent){
if(myevent.charCode >48 && myevent.charCode <=57){
}else{
myevent.preventDefault();
}
}
function addbookname(myevent){
if(myevent.charCode >=65 && myevent.charCode <=90){
}else if(myevent.charCode>=97 && myevent.charCode <=122){
}else if(myevent.charCode == 32){
}
else{
myevent.preventDefault();
}
}
function addbookauthor(myevent){
if(myevent.charCode >=65 && myevent.charCode <=90){
}else if(myevent.charCode>=97 && myevent.charCode <=122){
}else if(myevent.charCode == 32){
}
else{
myevent.preventDefault();
}
}
})();