:: Forum >>
Formating string
Is there a list for the formating strings(display mask) on this site? There are examples of how to do a date format, but what about text formating and number formating? Thnx.
Wai
Thursday, January 31, 2008
Alex (ActiveWidgets)
Thursday, January 31, 2008
With the following code. I was expecting '$ 29.01' to be displayed, but I am getting a blank input field. Anything I did wrong.
<html>
<script src="./ActiveWidgets/runtime/lib/aw.js"></script>
<link href="./ActiveWidgets/runtime/styles/system/aw.css" rel="stylesheet"></link>
<body>
Enter the Number :
<script>
var num = new AW.Formats.Number;
num.setTextFormat("$ #,###.##");
var obj = new AW.UI.Input;
obj.setControlFormat(num);
obj.setControlValue("29.01");
document.write(obj);
obj.onControlValidated = function(){
alert(this.getControlValue());
};
</script>
</body>
</html>
Wai
Thursday, January 31, 2008
Normally the input box work the other way round - from text to value. However you can force it to convert both ways -
var num = new AW.Formats.Number;
num.setTextFormat("$ #,###.##");
var obj = new AW.UI.Input;
obj.setControlFormat(num);
obj.setControlValue(29.01);
obj.setControlText(function(){
var value = this.getControlValue();
var format = this.getControlFormat();
return format.valueToText(value);
});
document.write(obj);
obj.onControlValidated = function(text){
var format = this.getControlFormat();
var value = format.textToValue(text);
var final = format.valueToText(value);
this.setControlValue(value);
this.setControlText(final);
};
Alex (ActiveWidgets)
Thursday, January 31, 2008
Thank you Alex. I thought that your tool library made it work both ways just like other libraries I have used in the past for Windows development.
Wai
Thursday, January 31, 2008
Alex,
One more help. I am not able to change the text-align style property of a input box by doing a obj.setStyle("text-align", "right"). However, labels and check boxes are OK. Is this specific to the AW-UI-Input?
Wai
Friday, February 1, 2008
This is a problem with IE implementation of the <input> element - it does not inherit the style settings of the parent. You have to set the style directly on the input box -
obj.getContent("box/text").setStyle("text-align", "right");
Alex (ActiveWidgets)
Monday, February 4, 2008
Thnx again, you are great help.
Wai
Monday, February 4, 2008
This topic is archived.
Back to support forum
Forum search