Tuesday, 15 June 2010

asp.net mvc - Html.TextBoxFor max length only count numbers mvc -



asp.net mvc - Html.TextBoxFor max length only count numbers mvc -

i want count numbers textarea count counts comma number. how can solve problem?

@html.textboxfor(m => m.money, new { @class = "w90 amount-align", @id = "input-amount", @maxlength = 11", @data_mask = "###.###.###", @data_mask_reverse = "true", @placeholder = "0" })

forget it. maxlength input attribute work input value char count. wherever if number, currency, text, etc.

then, need develop own custommaxlength self. this.

html:

<input type="text" id="field" class="maxlength-5">

jquery:

$(function(){ $('.maxlength-5').keypress(function(evt){ var maxlength = 5; // threat maxlength-5 custom class :) // assuming data-mask certify currency format valid var purevalue = $(this).val().replace('.','').replace(',',''); if(purevalue.length >= maxlength) evt.preventdefault(); });

});

try here.

asp.net-mvc razor

No comments:

Post a Comment