File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed
20-SessionStorage-TodoList Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,11 @@ function get_todos() {
1010
1111function add ( ) {
1212 var task = document . getElementById ( "task" ) . value . trim ( ) ; // remove extra spaces
13+ var alertMessage = document . getElementById ( "alert" ) ;
14+ alertMessage . style . display = "none" ; // hiding alert message initially
1315
1416 if ( task === "" ) {
15- alert ( "Please enter a task before adding!" ) ;
17+ alertMessage . style . display = "block" ; // show alert if task is empty
1618 return false ; // stop if empty
1719 }
1820
Original file line number Diff line number Diff line change 1010 < body >
1111 < div id ="wrapper ">
1212 < h1 > Todo List</ h1 >
13+ < p id ="alert "> Task field is empty</ p >
1314 < input type ="" id ="task " /> < button id ="add "> Add Task</ button >
1415 < div id ="todos "> </ div >
1516 </ div >
Original file line number Diff line number Diff line change 5353h1 {
5454 margin-top : 30px ;
5555}
56+
57+ # alert {
58+ display : none;
59+ color : red;
60+ font-weight : bold;
61+ margin-top : 10px ;
62+ }
You can’t perform that action at this time.
0 commit comments