-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (27 loc) · 1.11 KB
/
app.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
const courseName = document.querySelector('#courseName');
const courseRating = document.querySelector('#courseRating');
const courseAddBtn = document.querySelector('#courseAddBtn');
const courseList = document.querySelector('#courseList');
courseAddBtn.addEventListener('click',() => {
console.log('Js');
const enterdCourseName = courseName.value;
const enterdCourseRating = courseRating.value;
if( enterdCourseName.trim().length <=0 ||
enterdCourseRating.trim().length <=0 ||
enterdCourseRating <=0 ||
enterdCourseRating >5 )
{
const alert =document.createElement('ion-alert');
alert.header = "Invalid Courses Data ";
alert.message = "Please Enter a Valid Data";
alert.buttons = ['Okay'];
document.body.appendChild(alert);
alert.present()
return ;
}
const newCourse = document.createElement('ion-item');
newCourse.textContent = enterdCourseName + '(' + enterdCourseRating +' / 5)' ;
courseList.appendChild(newCourse);
courseName.value = '';
courseRating.value = '';
});