Can't submit form


#1

Hello

I want to add an item to my list after pressing Enter button.
But its not working. Here comes my code:

Can you please inform me. Is anything else wrong with my code:


<template name="addTodo">

    <form>
        Create a task:
        <input type="text" placeholder="Type a task here....." name="todoName">
    </form>

</template>
 Template.addTodo.events({

        'submit form': function(event){
            event.preventDefault();
            var todoName =$('[name="todoName"]').val();
            

            Todos.insert({

                name : todoName,
                completed : false,
                createdAt : new Dat()


            });
            $('[name="todoName"]').val('');


        }

    });

regards,
Saeed


#2

Forms without a submit button can’t be submitted, not even by pressing enter in an input field.