Skip to content

Commit b5960e5

Browse files
ikoevskarigor789
authored andcommitted
Added empty string check (#232)
1 parent 043b97e commit b5960e5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: content/docs/en/getting-started/2-playground-tutorial.md

+4
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ Use a `<ListView>` to show tasks below the input field.
233233
* Replace the `countries`-related binding with a binding to your array of active tasks.
234234
* In the `<script>` block, remove the array of countries and create an empty array for your active tasks.
235235
1. In the `<scripts>` block, tie some logic to the tapping of the button.
236+
* Check if the input is an empty string.
236237
* Log newly added tasks in the console.
237238
* Add newly added tasks into the array of active tasks. Use `unshift` to place new items at the top of the page.
238239
* Clear the text field after input.
@@ -279,6 +280,7 @@ export default {
279280
},
280281
281282
onButtonTap() {
283+
if (this.textFieldValue === "") return; // Prevents users from entering an empty string.
282284
console.log("New task added: " + this.textFieldValue + "."); // Logs the newly added task in the console for debugging.
283285
this.todos.unshift({ name: this.textFieldValue }); // Adds tasks in the ToDo array. Newly added tasks are immediately shown on the screen.
284286
this.textFieldValue = ""; // Clears the text field so that users can start adding new tasks immediately.
@@ -420,6 +422,7 @@ export default {
420422
},
421423
422424
onButtonTap() {
425+
if (this.textFieldValue === "") return; // Prevents users from entering an empty string.
423426
console.log("New task added: " + this.textFieldValue + "."); // Logs the newly added task in the console for debugging.
424427
this.todos.unshift({
425428
name: this.textFieldValue
@@ -569,6 +572,7 @@ export default {
569572
},
570573
571574
onButtonTap() {
575+
if (this.textFieldValue === "") return; // Prevents users from entering an empty string.
572576
console.log("New task added: " + this.textFieldValue + "."); // Logs the newly added task in the console for debugging.
573577
this.todos.unshift({
574578
name: this.textFieldValue

0 commit comments

Comments
 (0)