Sumedha Vangury
Sumedha Vangury

Reputation: 683

convert text to UpperCase in mvc

Hi I am trying to convert the text entered in textbox to uppercase, but I am not getting the output,please help.

 @Html.TextBoxFor(model => model.PanNumber, new { @class = "form-control", @onkeyup = "InputToUpper(this);" })

Upvotes: 0

Views: 3610

Answers (2)

prashant pathak
prashant pathak

Reputation: 19

if you are using "@editorfor" text box then try

@Html.EditorFor(model => model.PanNumber.Alias, new { 
       htmlAttributes = new { @class = "upper-case" }
}) 

Upvotes: 0

user3559349
user3559349

Reputation:

This should work (remove @onkeyup = "InputToUpper(this);" from the TextBoxFor method)

$('#PanNumber').keyup(function() {
  var text = $(this).val();
  $(this).val(text.toUpperCase());
});

Upvotes: 4

Related Questions