CNPJ Field with Mask

0

I'm a beginner in both ASP.NET and jQuery. I need to include a mask in the CNPJ field of my View, but I can not. I'm going to post my code and someone, please tell me where I'm wrong.

Bundle

using System.Web;
using System.Web.Optimization;

namespace macpartner
{
    public class BundleConfig
    {
        // For more information on bundling, visit https://go.microsoft.com/fwlink/?LinkId=301862
        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                        "~/Scripts/jquery-{version}.js"));

            bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                        "~/Scripts/jquery.validate*"));

            bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                        "~/Scripts/jquery.maskedinput*"));

            // Use the development version of Modernizr to develop with and learn from. Then, when you're
            // ready for production, use the build tool at https://modernizr.com to pick only the tests you need.
            bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                        "~/Scripts/modernizr-*"));

            bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                      "~/Scripts/bootstrap.js",
                      "~/Scripts/respond.js"));

            bundles.Add(new StyleBundle("~/Content/css").Include(
                      "~/Content/bootstrap.css",
                      "~/Content/site.css"));
        }
    }
}

View

@model macpartner.Models.Lead

@{
    ViewBag.Title = "Create";
}

@section Scripts {
    <!-- não esqueça de criar o bundle -->
    @Scripts.Render("~/bundles/jquery/maskedinput")

    <script>
        $(document).ready(function () {
            $("#cnpj").mask("99.999.999/9999-99")
        });
    </script>
}

<h2>Create</h2>

@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <h4>Lead</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.LabelFor(model => model.cnpj, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.cnpj, new { htmlAttributes = new { @class = "cnpj"} })
                @Html.ValidationMessageFor(model => model.cnpj, "", new { @class = "text-danger" })
            </div>
        </div>
    
asked by anonymous 29.09.2018 / 21:14

0 answers