When I press enter in input type file, it opens a blank page

Asked

Viewed 48 times

0

This is my code, when pressing enter it opens a blank page

<div class="form-group">
            <div class="col-sm-12">
                <div id="fileselection" style="margin-bottom:30px">
                    @using (Html.BeginForm("AdicionarAnexo", "Classe", FormMethod.Post, new { @encoding = "multipart/form-data", @enctype = "multipart/form-data", @id = "AnexoClasseForm", @class = "upload-form" }))
                    {
                        if (ViewBag.Status == null)
                        {
                            <div class="col-sm-5">
                                <input type="file" name="anexo" id="idAnexo" />
                            </div>
                            <div class="col-sm-6">
                                <input type="button" class="btn btn-default" id="adicionarAnexo" value="Incluir anexo" style="margin-top:-10px;" />
                            </div>
                        }
                    }
                </div>
            </div>
            @*<h4><i class="fa fa-question-circle" data-container="body" data-toggle="popover" data-placement="right" data-content="texto"></i></h4>*@
        </div>

That is the input:

enter image description here

  • 1

    Tested in more than 1 browser?

  • 1

    In the other browsers there is this problem, because they do not have this input field, just search..., I managed to solve, I will post the solution, very simple...

1 answer

1

I cancel the Enter key in the Form:

I added on Beginform:

new { onkeydown = "return event.keyCode!=13",

The complete Code:

@using (Html.BeginForm("AdicionarAnexo", "Classe", FormMethod.Post, new { onkeydown = "return event.keyCode!=13", @encoding = "multipart/form-data", @enctype = "multipart/form-data", @id = "AnexoClasseForm", @class = "upload-form" }))
  • Asked and also answered!!! This congratulations!!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.