<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>To Do List</h1>
<form>
<input autocomplete="off" autofocus id="todotext"
type="text">
<input onclick="serve(); return false" type="submit">
</form>
<ol id="add"></ol>
</body>
<script>
function serve(){
const neww = document.getElementById('add')
let text = document.getElementById('todotext').value
const a = document.createElement('li')
a.innerText = text
neww.appendChild(a)
document.getElementById('todotext').value = ""
}
</script>
</html>
Here is my code and I want to return an 'Alert' if someone submit empty form. How should I do it ?
Here's an image:
Read more here: https://stackoverflow.com/questions/65840049/i-want-to-return-alert-box-if-someone-submits-empty-form
Content Attribution
This content was originally published by Rakshit Joshi at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.