简体   繁体   中英

Value from form input does not be transmit by the submit button. How can I fix that?

i try to add fields in a form by clicking a button. The fields appear and the validation works either. The problem is, that the value of these input fields isn't transmitted by the submit button of the form.

The framework is ASP.NET Core-Web-App (Model View Controller) with.Net 5.

I add the fields with the following code.

 putMoreFields.addEventListener("click", function () {
    
    myTextField.insertAdjacentHTML('afterend',
        '<label asp-for="ContactMail" class="form-label"></label> <input type="email" class="form-control" asp-for="ContactMail" placeholder="name@example.com" required> <span asp-validation-for="ContactMail" class="text-danger"></span> </div> <div class="invalid-feedback"> Bitte geben Sie eine Mail-Adresse ein. </div> </div >')
    myTextField.insertAdjacentHTML('afterend',
        '<label asp-for="ContactMail" class="form-label"></label> <input type="date" class="form-control" asp-for="ContactMail" placeholder="dd.mm.jjjj" required> <span asp-validation-for="ContactMail" class="text-danger"></span> </div> <div class="invalid-feedback"> Bitte geben Sie eine Mail-Adresse ein. </div> </div >')
    
})

Can someone help me?

Best regards

JuRi-2020

You just need change all the code

asp-for="ContactMail"

to

 name="ContacMail"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM