HTML validation der Jquery mask

Asked

Viewed 17 times

-1

Guys I have an ASP.NET MVC screen using Razor, which in Edit return data that has already been saved for editing. In one of my fields is of type (decimal) use to save monetary value. This field when I give the post to execute the editing in the controller for in HTML nor going to the controller returning the following messages.

The field Cost must be a number.

Obviously, he says it is a string (due to a mask) and not a decimal number as the model type. Here’s what I find strange that I use the same html code in the new CREATE view and do not stop at this validation.

Does anyone have any id~What may be occurring?

Follows the code:

    @Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/modalform")
<script src="~/Scripts/jquery.maskedinput-1.3.1.min.js"></script>
<script src="~/Scripts/jquery.moneymask.js"></script>

<div class="input-group">
                            <span class="input-group-addon">R$</span>
                            @Html.EditorFor(model => model.Cost, new {htmlAttributes = new {@class = "form-control", autofocus = "autofocus", required = "required"}})
                            @Html.ValidationMessageFor(model => model.Cost, "", new {@class = "text-danger"})
                        </div>
                    </div>
                </div>
                <p></p>
                <br/>
                <div class="row">
                    <div class="col-sm-11" style="text-align: left">
                        <input type="submit" value="SALVAR" class="btn btn-primary"/>
                    </div>
                </div>

1 answer

0

I discovered the problem was in this render script:

@Scripts.Render("~/Bundles/jqueryval")

After removing it everything went well.

Browser other questions tagged

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