PDA

View Full Version : inputtext, pattern, number, float


ebrentnelson
06-28-2006, 08:32 AM
I am using the pattern attribute in the inputtext tag to limit my users to only be able to enter numbers and a decimal(ie [0-9.]* ), but the problem I am running into is that the user is able to enter the following:

15.15..15

Is there a way to only allow them to enter ONE decimal?

thank you.

ebn

jstretch
06-28-2006, 12:21 PM
The following is for floating point numbers, however I believe laszlo doesn't fully support regular expressions.

[0-9]*\.?[0-9]*

To get full functionality of regexp read the following:

http://www.laszlosystems.com/developers/community/forums/showthread.php?threadid=2622

http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=5407

Not sure if they have added full regexp support yet, these posts are abit dated.

ebrentnelson
06-28-2006, 12:52 PM
Darn, well I guess I will need to just validate it separately...

Thanks a lot.

ebn

nyoon
06-28-2006, 02:11 PM
I tackled exactly this problem yesterday. Here's a simple class extending edittext that allows only valid numbers with a single decimal point. It works by removing any decimal point typed after the first one. It's kludgy but it does work while the user types without using any distracting messages. I'm sure there are more clever ways to do it, but perhaps this will help.

Cheers,

ny