Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
70
Set maxlength on TextEditor
posted

I have an Asp.net MVC/Razor app using the Infragistics JQuery controls and I would like to limit the number of characters entered in a igTextEditor. On my page I have

@(Html.Infragistics().TextEditorFor(m=>m.Name).ID("assemblyNameEditor").ValidatorOptions(m=>m.OnBlur(true).OnSubmit(true).FormSubmit(true).KeepFocus(ValidatorKeepFocus.Once)).Required(true)

and then down in my JQuery script section I have

$("#assemblyNameEditor").igTextEditor("option", "maxLength", 10);

when looking at the rendered page I see that the maxlength attribute was not added. SO then I just used simple jquery to add the maxlength attribute ...

$("#assemblyNameEditor").attr("maxLength", 10);

which rendered fine but for some reason was still not limiting the characters.

So then I was I hoping I could at least decorate my model with DataAnnotations such as

[StringLength(20, ErrorMessage = "Must be under 20 characters")]

and have have validation catch it on submit, but that didn't work either.

Not sure what else to try??

Parents Reply Children
No Data