Field format for unsigned ints

Questions and answers for designing and implementing forms in Servoy

Field format for unsigned ints

Postby nromeou » Wed Apr 06, 2011 12:35 am

Hi everybody,
I would like to have a text field with some format that would accept only unsigned ints.
Does somebody know how to do this??
I feel is much better than using a onDataChange validation.

Thanks for the help

Cheers
nromeou
 
Posts: 215
Joined: Fri Sep 18, 2009 8:38 pm
Location: Montevideo, Uruguay

Re: Field format for unsigned ints

Postby goldcougar » Sat Apr 09, 2011 7:21 am

You might want to try using a column converter instead. You can just change the sign so that its always positive.

Or if you must have it as a format, maybe something like this as the format:
Code: Select all
#;INVALID


The ; should separate the format so left side is positive values and right side is negative, so you just display something in there so the user knows its bad input. I haven't tried it, but that is a valid java DecimalFormat.

Another option might be to combine the format with a column converter. So if you assign the format of "#;#" then java should leave off the minus sign "-" on the negative value, so it will always look positive in the field. Then use the column converter to actually make it always positive.
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Free Training Videos
Servoy Guy- Free Plugins, Tips & Resources
ServoyForge- Open Source Servoy Components
User avatar
goldcougar
Servoy Expert
 
Posts: 662
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH

Re: Field format for unsigned ints

Postby nromeou » Fri Apr 15, 2011 7:43 pm

Thank you Scott, it worked like a charm.
nromeou
 
Posts: 215
Joined: Fri Sep 18, 2009 8:38 pm
Location: Montevideo, Uruguay

Re: Field format for unsigned ints

Postby maria.kyselova » Wed Feb 20, 2013 2:18 am

goldcougar wrote:You might want to try using a column converter instead. You can just change the sign so that its always positive.

Or if you must have it as a format, maybe something like this as the format:
Code: Select all
#;INVALID


The ; should separate the format so left side is positive values and right side is negative, so you just display something in there so the user knows its bad input. I haven't tried it, but that is a valid java DecimalFormat.

Another option might be to combine the format with a column converter. So if you assign the format of "#;#" then java should leave off the minus sign "-" on the negative value, so it will always look positive in the field. Then use the column converter to actually make it always positive.


That was helpful, thanks.
Cheers,
Maria
maria.kyselova
 
Posts: 172
Joined: Thu Aug 09, 2012 12:56 am


Return to Forms

Who is online

Users browsing this forum: No registered users and 2 guests

cron