Duk
Duk

Reputation: 927

In mvc2 or jquery how to set limited characters in textbox

I have Address field in my web form.. I want to limit the characters in that textbox.. I don't know how to do this by mvc2..

My html code

<%: Html.TextBox("Address",Model.Address, new {@title="Enter your address"}) %>

If any chances in jquery is there means it will ok..

Upvotes: 0

Views: 104

Answers (1)

Paritosh
Paritosh

Reputation: 11588

Here it is maxlength="x" where x: length

<%: Html.TextBox("Address",Model.Address, new {@title="Enter your address", @maxlength="10"}) %>

Or using jQuery,

$('#Address').attr('maxlength', '10');

Upvotes: 1

Related Questions