on 09-12-2006 7:48 AM
Hi all,
Is there any way to check maximum length of the Input field like we check for the strings using Local Dictionary. My inputfield is of float type, I want the user to type only 10 digits not more than that.
Is there any standard ways available for this or we have to go for customized way. If any body knows, Plz tell me. Thanks in Advance.
Hi,
You can always do this:
1. Create a simple type of base type string and fix the max. length to 10.
2. Create a context attribute of this simple type.
3. Bind the attribute to your input field.
4. Then in your code you can convert it back to float through:
Float.parseFloat(<string attribute bound to inputfield>);
Regards,
Satyajit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Satyajit,
Funny, you provided only half of solutuion:
1. Create a simple type of base type <b>long or double</b> and fix the max. / min. <b>value</b> to 9999999999 and 0.
2. Create a context attribute of this simple type.
3. Bind the attribute to your input field.
4. No necessary.
Valery Silaev
EPAM Systems
Thanks for your quick reply.
What my question is, is there any way to specify the maximum length for input field who's type is float without converting them in to string. Becoz i am using it as float in many places.I don't want to convert it in to string. For this validation only i need this in string format.
Hi Valery,
What I thought of the original question is that Krishnaveni wants a solution similar to fixing the maxlength of an inputfield. There you cannot type beyond the number of characters fixed by the max length of the simple type.
Your solution is also very much valid, but if the user puts in more than the value allowed, he has no way of knowing of the restriction until he does a postback. So basically he will miss the "client side" thing here :). Isn't it?
Regards,
Satyajit.
Satyajit,
Correct, number validation occurs only after post-back to server. However, your original solution has the very same problem: AAAAAAAAAA is valid on client-side, but rejected on server side. However, in my solution there is no need to validate "float" manually via parsing.
Valery Silaev
EPAM Systems
once again thanks for all your inputs.
I followed the same steps as you specified.
It is accepting the values of 9999999999 this length, not as my reqirement of 10 digits only. If I am wrong plz correct me, I have to create a simple type whose built in datatype is float. If I select this, min & max inclusive/exclusive fields are enable in the simple type.
User | Count |
---|---|
95 | |
11 | |
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.