Glory Raj
Glory Raj

Reputation: 17701

How to apply maxlength property using jQuery

I have a kendo ui control that create following html syntax on runtime

<input id=​"ItemSearch" name=​"ItemSearch" style=​"width:​115px;​" type=​"text">​

How can I apply the maxlength HTML5 property to it using javascript

When I use following I am getting Cannot call method 'prop' of undefined

 $('#ItemSearch').input.prop("maxlength", 2);

Upvotes: 0

Views: 77

Answers (1)

Rory McCrossan
Rory McCrossan

Reputation: 337560

You don't need .input as $('#ItemSearch') has already selected that element. Try this:

$('#ItemSearch').prop("maxlength", 2);

Upvotes: 5

Related Questions