create custom mask

Asked

Viewed 141 times

2

How do I create a custom mask for a particular field? The mask will be in the following format: ____OB_____ (4 numbers + OB + 5 numbers)

The image below shows the example I want to follow:

inserir a descrição da imagem aqui

1 answer

4


Use the Nuget package jQuery.Maskedinput.

In the View:

@section scripts {
    <script>
        $("#OrdemBancaria").mask("9999OB99999");
    </script>
}

Usually I use the Bundle thus:

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js",
                    // Alguns JS aqui
                    "~/Scripts/jquery.maskedinput.js",
                    // Mais alguns aqui
                    ));

Browser other questions tagged

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