Editor HTML5 'number'-field

Editor HTML5 'number'-field

btreebtree Posts: 99Questions: 14Answers: 11
edited October 2015 in Plug-ins

Just a simple HTML5 number Field.

Plugin Code:

_fieldTypes.number = {
    create: function ( conf ) {
        var that = this;
        conf._input = $( 
            '<input id="'+conf.id+'" name="'+conf.name+'" type="number" class="form-control">')[0];
        return conf._input;
    },

    get: function ( conf ) {
        return $(conf._input).val();  //return the field value POST
    },
    set: function ( conf, val ) {
        $(conf._input).val(val);  //set the field value
    }
};

After you saved the Plugin Code you can simple use "number" as type.

{
label: 'Number'
name: 'numberfield',
type: 'number'
}

Replies

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin

    Hi,

    Another option is to use the attr option of the text field type to set the type property:

    {
      name: "myfield",
      attr: {
        type: "number"
      }
    }
    

    I didn't set the fields.type property as it is text by default.

    Allan

  • btreebtree Posts: 99Questions: 14Answers: 11

    .. tzz thank you :) a lot easier!

This discussion has been closed.