Fork me on GitHub

Example: Basic string textarea creation

How to create a textarea field.

Basic Textarea creation

Use the following code to create a basic inputEx Textarea.

Textarea setValue/getValue

Test of the setValue, getValue methods

Change Textarea size

Set the size using "rows" and "cols" attributes.

More options

Set the min/max length, placeholder...

HTML

<div id="field-container"></div>

JavaScript

Implementation

YUI().use('inputex-textarea',function(Y) {

    // Example 1
    new Y.inputEx.Textarea({parentEl: 'container1', value: 'Textarea can contain\nmultiline text !\n'});

    // Example 2
    var div = Y.one('#container2');
    var textField = new Y.inputEx.Textarea({parentEl: div, showMsg:true, required:true});

    var button1 = Y.inputEx.cn('button', null, null, "SetValue");
    div.appendChild(button1);
    Y.on("click" ,function() {
        textField.setValue('Textarea can contain\nmultiline text !\n');
    },button1);

    var button2 = Y.inputEx.cn('button', null, null, "GetValue");
    div.appendChild(button2);
    Y.on("click" ,function() {
        alert(textField.getValue());
    },button2);


    // Example 3
    new Y.inputEx.Textarea({parentEl: 'container3', value: 'Set the size...\nusing "rows" and "cols" attributes !\n', rows: 8, cols: 40});

    // Example 4
    new Y.inputEx.Textarea({parentEl: 'container4', showMsg:true, required:true, placeholder:"Type text here", minLength:10, maxLength:20, name: "Test4"});

});