-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
19 lines (14 loc) · 852 Bytes
/
Copy pathmain.js
File metadata and controls
19 lines (14 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import zip from './zip/index.js';
const formSearch = document.querySelector('#formSearch');
const result = document.querySelector('#result');
formSearch.addEventListener('submit', (e) => {
e.preventDefault();
const zipCode = formSearch.zipCode.value.trim();
result.innerHTML = '';
if(zipCode !== '') {
const found = zip.search(zipCode);
result.innerHTML = found ? `<code>{ <br/> type : "${found.type}", <br/> area : "${found.area}", <br/> location: "${found.location}", <br/> zipCode : "${found.zipCode}", <br/> tag : ${found.tag ? '"'+found.tag+'"' : null} <br/>}</code>` : `<b>${zipCode}</b> Not Found`;
console.log(found);
}
formSearch.zipCode.focus();
});