如何在 mvc razor 页面中将我所有的文本框输入字母更改为大写?
How to change all my textbox input letters to uppercase in mvc razor page?
这是我的文本框
<div class="col-md-10">
@Html.EditorFor(model => model.FirstName, new { htmlAttributes = new { @class = "form-control", @placeholder = "First Name"} })
@Html.ValidationMessageFor(model => model.FirstName, "", new { @class = "text-danger" })
</div>
你可以使用 js:
$(function () {
$("input").each(function () {
$(this).val($(this).val().toUpperCase());
})
})
当页面loaded.If你想在输入失去焦点时将我的所有文本框输入字母更改为大写时,它会将所有输入的值更改为大写,你可以使用:
$("input").change(function () {
$(this).val($(this).val().toUpperCase());
})
这是我的文本框
<div class="col-md-10">
@Html.EditorFor(model => model.FirstName, new { htmlAttributes = new { @class = "form-control", @placeholder = "First Name"} })
@Html.ValidationMessageFor(model => model.FirstName, "", new { @class = "text-danger" })
</div>
你可以使用 js:
$(function () {
$("input").each(function () {
$(this).val($(this).val().toUpperCase());
})
})
当页面loaded.If你想在输入失去焦点时将我的所有文本框输入字母更改为大写时,它会将所有输入的值更改为大写,你可以使用:
$("input").change(function () {
$(this).val($(this).val().toUpperCase());
})