UnitText.js
=======================
// Put the word unitText after the input box textfield definition:
Ext.override(Ext.form.TextField, {
unitText : '',
onRender : function(ct, position) {
Ext.form.TextField.superclass.onRender.call(this,ct, position);
if (this.unitText != '') {
this.unitEl =ct.createChild({
tag: 'div',
html: this.unitText this.unitEl.addClass('x-form-unit'); this.width =this .width
-(this.unitText.replace(/[^x00-xff]/g, "xx").length * 6 2); this.alignErrorIcon= function() {
this.errorIcon.alignTo (this.unitEl,'tl-tr', [2, 0]); }});
Put UnitText.js into the jsp file and add css style, as follows:
This way you can use it. The usage method is as follows:
var jine = new Ext.form.NumberField({
id: 'je' ,
fieldLabel: 'Amount',
allowDecimals: true, // Allow decimal points?
allowNegative: false, // Allow negative numbers?
width: 100,
style: 'text-align:right',
unitText: '元'
});