control editor input format

control editor input format

tigeritstigerits Posts: 4Questions: 0Answers: 0
edited December 2012 in Editor
Hi All,

I am new to editor, here is a simple question, how to control the text input max length, I can not seem to find a document to mention this.

What I want is:
[code]
{
"label": "Code:",
"name": "code",
"type": "text",
"maxLength": "4"
}
[/code]
is there a maxlength attribute available?

Thanks a lot.

Tiger

Replies

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin
    Hi Tiger,

    There actually isn't a Javascript API to add that option to the text input at the moment, although that is something that will be introduced in the next version of Editor, including the ability to specify `email` etc type input options.

    At the moment what you could do is use the `onOpen` event and add the attribute to your input element. For example:

    [code]
    editor.on( 'onOpen', function () {
    // Get the 'input' element from the 'code' input field and set an attribute on it
    $( 'input', this.node( 'code' ) ).attr( 'maxLength', 4 );
    } );
    [/code]

    Regards,
    Allan
  • tigeritstigerits Posts: 4Questions: 0Answers: 0
    Thanks a lot.
This discussion has been closed.