cancel
Showing results for 
Search instead for 
Did you mean: 

Validations for Input Field

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

http://www.NetWeaverTeam.com

Former Member
0 Kudos

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.

Former Member
0 Kudos

krishnaveni,

Look at my previous post in this thread.

VS

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

http://www.NetWeaverTeam.com

Former Member
0 Kudos

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.

Former Member
0 Kudos

krishnaveni,

If you need exactly 10 digits (with leading zeros or whatever) use custom simple type based on String and convert to float manually. No other way.

If you need float with up to 10 digits (equals or less) then use simple type based on Float.

VS

Answers (0)