Form fields - javascript generated --> error

I have a complex js array with a lot of values to be send via hidden form-fields to the server (I cannot send it as a single value).
Therefore I used javascript (looping over the array) to create specific ID’s and names, like so:

        ...var textfield = document.createElement("input");
        textfield.type = "hidden";     
        textfield.id = 'form-field-' + key1 + 'abcd';
        textfield.name = 'form-field-abcd' + key1;
        textfield.value = key1_value;
        document.getElementById(form_ID).appendChild(textfield);

which gives me the field

        <input type="hidden" id="form-field-11abcd" name="form-field-abcd11" value="xyz">

As a result I get an error from the form validation.

Question:
Which information are needed to create a valid hidden form field which can be processed as a usual bricks form field? Is it possible to create js-based fields or do I have to create them manually in the form (and later fill the values via js)?
Annotation: only the name attribute seems to causes the error…