-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpractice.js
31 lines (30 loc) · 903 Bytes
/
practice.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
const but = document.querySelector('button');
const bod = document.querySelector('body');
let count = 0;
but.addEventListener('click',function ()
{
event.preventDefault()
const inr = document.querySelector('#amount').value;
const type = document.querySelector('#type').value;
const desc = document.querySelector('#decription').value;
if(inr>=0 && type.length>0)
{
const newElement = `<div>Amount = ${inr}, Type: ${type}, Description: ${desc}</div>`;
if(count == 0)
{
document.querySelector('#container').innerHTML = newElement;
count++;
}
else
{
document.querySelector('#container').innerHTML += newElement;
count++;
}
const formm = document.querySelector('form');
formm.reset();
}
else
{
alert('Invalid Number or empty type');
}
});