如何为使用JS创建的表单创建CSRF字段

I created a form in JS by using the .createElement function to create the form elements. My trouble is I created the CSRF token the same way but I always get the "token mismatch" error. Here's my code

function sem(term)
{
if(sem==1)
    {
var doc = document.getElementById("list_of_courses");
        var createform = document.createElement('form');

            createform.setAttribute("action","reg_save");
            createform.setAttribute("method","post");
            doc.appendChild(createform);

        var csrf = document.creatElement('input');
            csrf.setAttribute("type","hidden");
            csrf.setAttribute("id","_token");
            csrf.setAttribute("value","{{csrf_field()}}")
            createform.appendChild(csrf);

        var linebreak = document.createElement('br');
        var Algebra = document.createElement('input');
            Algebra.setAttribute("type","checkbox");
            Algebra.setAttribute("name","FAEN101");
            createform.appendChild(Algebra);


}
}

You set the id of your created input tag instead of name.

here you go..

csrf.setAttribute("name","_token");