Skip to content

Instantly share code, notes, and snippets.

Created Aug 23, 2020
What would you like to do?
<!DOCTYPE html>
<base target="_top">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello Bulma!</title>
<link rel="stylesheet" href="">
<section class="section">
<div class="container">
<h1 class="title">
Add new Customer
<div class="field">
<div class="control">
<input id="input-id" class="input is-primary" type="text" placeholder="ID">
<div class="field">
<div class="control">
<input id="input-first-name" class="input is-primary" type="text" placeholder="First Name">
<div class="field">
<div class="control">
<input id="input-last-name" class="input is-primary" type="text" placeholder="Last Name">
<div class="field">
<div class="control">
<input id="input-email" class="input is-primary" type="text" placeholder="Email">
<div class="buttons">
<button id="btnSaveCustomer" class="button is-primary">Save customer</button>
const btnSave = document.getElementById("btnSaveCustomer");
btnSave.addEventListener("click", themDuLieu);
function themDuLieu() {
const inputId = document.getElementById("input-id").value;
const inputFirstName = document.getElementById("input-first-name").value;
const inputLastName = document.getElementById("input-last-name").value;
const inputEmail = document.getElementById("input-email").value;
if(inputId.length == 0 || inputFirstName.length == 0 || inputLastName.length == 0 || inputEmail.length == 0) {;
} else {
const data = {
id: inputId,
firstName: inputFirstName,
lastName: inputLastName,
email: inputEmail
inputId = "";
inputFirstName = "";
inputLastName = "";
inputEmail = ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment