Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

EpiServer Forms: TextboxElementBlock how do I add attributes like maxlength?


I want to add maxlength to my input textbox (I use epiServer Forms 4.2.1), but I can't do this in epiServer CMS.

There is an option to make this work? There is a clue in the code that it is supported:

<%: html.raw(model.attributesstring) %>

Jan 24, 2017 17:10

One of the way is to override display template for this element and take control of resulting markup yourself.

Jan 25, 2017 7:55

I understand this is an option, but there is no away to fill this 'AttributesString'? Because when you decompile the source code, you can see that a key value pair is rendered to html properties into the ascx.

I just can't figure out where to fill these values..

Jan 25, 2017 9:20

Model.AttributesString is constructed based on available validators for particular form field block.

For instance by default for input field, following validators are available:

Jan 25, 2017 10:52

BlockBase.AttributeString calls BlockBase.GetAttributes()

If you want to add new attribute to the output of BlockBase.AttributeString, please modify the GetAttributes()

TextBoxBlock is just a built-in element. If you want to change default behaviour of (built-in) TextBox, I think you should override its template and business to your own need, to create your customizedTextBoxBlock element.

Mar 06, 2017 8:44

i see email validation on text field doesnt work and we still get spam (in email field as non emails) . How can we enable server side validation for text field ?

Jan 03, 2020 11:07

Hi, the EmailValidator will validate on both client side and server side as default. You can disable javascript on browser to see if it validate.

Jan 13, 2020 6:42
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.