diff --git a/etemplate/js/et2_widget_textbox.js b/etemplate/js/et2_widget_textbox.js index 8ec0737c4a..79801e917a 100644 --- a/etemplate/js/et2_widget_textbox.js +++ b/etemplate/js/et2_widget_textbox.js @@ -36,6 +36,12 @@ var et2_textbox = et2_inputWidget.extend({ "default": et2_no_init, "description": "Field width" }, + "maxLength": { + "name": "Maximum length", + "type": "integer", + "default": et2_no_init, + "description": "Maximum number of characters allowed" + }, "blur": { "name": "Placeholder", "type": "string", @@ -57,6 +63,8 @@ var et2_textbox = et2_inputWidget.extend({ } }, + legacyOptions: ["size", "maxLength"], + init: function() { this._super.apply(this, arguments); @@ -115,6 +123,18 @@ var et2_textbox = et2_inputWidget.extend({ } }, + /** + * Set maximum characters allowed + * @param _size Max characters allowed + */ + set_maxLength: function(_size) { + if (typeof _size != 'undefined' && _size != this.input.attr("maxlength")) + { + this.maxLength = _size; + this.input.attr("maxLength", this.maxLength); + } + }, + set_blur: function(_value) { if(_value) { this.input.attr("placeholder", _value + "!"); // HTML5