Another question for you all. I have numeric fields on a form.
If we type in alpha then numeric value (" BX124.5") , it will turn the field red and not accept the data,
however, if i type in numeric then alpha ("124.5BX33), it will accept the entry, just omitting number after the alpa value.
For our solution, we definitely need to not allow ANY alpha entry into numeric fields. An error message pop up would be best. Is there a way for that in servoy?
sammyzheng:
For our solution, we definitely need to not allow ANY alpha entry into numeric fields. An error message pop up would be best. Is there a way for that in servoy?
At the moment, I don’t know of any way to do this. The issue is that you can’t simply trap and test for a valid number (which you can with [1] Number(fieldValue) and [2] isNaN(fieldValue) in addition to Marcel’s plugin) because number fields absolutely don’t allow alpha characters to be entered first in the field.
So if you enter " BX124.5" in a numeric field, the value goes nowhere. Hence, you can’t test for it in any method. Even if you turn off auto-save on the form.
This is a good question and one which I wish had a better solution.
Thanks for your help guys. I’ll poke around and see if we can find a workaround. Maybe the servoy guys are listening and can offer up something in their later releases.
IT2BE:
Why don’t you evaluate the input ondatachange.
You can:
add a global to the field
onrecordselect add data from table/column to the field
on datachange capture the data
evaluate data and throw possible error
change table/column to new value when validated
Hope this helps a little
Doesn’t work. If alpha characters are entered first into a numeric field, that field literally doesn’t have that data in it. Whether global numeric or table numeric, the last valid value that was in that field is what is actually there even though your new value is displayed in red on the form.
Ah yes, I stand corrected. That definitely works for what it is. However, I would love to see a better solution that can be applied directly to numeric fields without having to go through a global every time…
No not silly. Maybe I can come up with a change to the samples.
I am on the European system but the bulk, I guess, will use the point as decimal seperator.
BTW there IS a system to work without globals. I have placed somewhere on this forum or on Servoy Magazine (can’t remember where) a tip how to work with fields without a dataprovider and still being able to grab the input data. I think however that you can’t use it with an ondatachange event but need to work with onfocuslost instead.