on 01-08-2014 12:40 PM
Hi All,
I am trying to restrict for a Text field for entering more than 10 characters in the UI , using "Type System".
Below is the piece of code from Demo kit:
// creating of a float type with 2 format options and one constraint
var oFloat = new sap.ui.model.type.Float(
{
minFractionDigits: 2,
maxFractionDigits: 2
},
{
maximum: 10
}
);
var oText = new sap.ui.commons.TextField({value: {path: "/sliderValue", type: oFloat}});
oText.bindValue("/sliderValue", oFloat);
But the Text Field is allowing more than 10 characters .
Please help me in this..
Hi Aisurya,
Use below one..
var oText = new sap.ui.commons.TextField({
maxLength:10,
value: {path: "/sliderValue", type: oFloat}
});
Regards,
Surendra.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In your first example you are configuring that the maximum value can be 10.00 on the data type, which you can then implement the validation handlers to determine if the format is correct or display error message etc.
attachFormatError
attachParseError
attachValidationError
attachValidationSuccess
The example that Surendra has provided is setting the maximum length of characters on the TextField control, will restrict to 10 characters rather an a particular value.
Jason
The value: {path: "/sliderValue", type: oFloat} code binds the control to the model data.
Setting the length will not prevent entering of invalid characters/format or validating the actual value.
Here is a working exampl of the validation.
http://jsbin.com/EKEgAneh/1/edit?html,output
Jason
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.