This feels like it should be a really easy one...
I've a dual purpose, form field that I want the user to enter either a DOB or an age in. So the field is set as a Char and I'm validating the input in fpl to determine if they've entered an age or DOB.
Where the field is 1 or 2 characters long, I want to check that they're numeric (an age) so I can error back to the user if not.
But I can't seem to find a 'isNumeric' function or similar in fpl? Am I missing it or any other ideas on how I can check in fpl if the Chars are numeric?
isNumeric?
Moderators: Jon, Steve, Ian, Dave
- Jez
- Ebase User
- Posts: 31
- Joined: Thu Aug 21, 2008 11:03 am
- Location: Hampshire County Council
-
- Ebase User
- Posts: 331
- Joined: Mon Mar 10, 2014 8:34 am
Hi, try the following in JS, you can call a JS function from FPL.
It returns a boolean.
Code: Select all
isNaN(value);
0 x
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
It's a bit harder in FPL, but you could use this - it will only return true for integers which seems to be what you need.
Code: Select all
if [tostring(javaMethod('org.apache.commons.lang.StringUtils.isNumeric', FIELD1)) = 'true']
0 x
- Jez
- Ebase User
- Posts: 31
- Joined: Thu Aug 21, 2008 11:03 am
- Location: Hampshire County Council
Fantastic! Thanks both for two great answers - I've tested both and they both work well.
I created a JS script with Steve's isNAN code and called it using callscript from my fpl script. This works nicely, setting another field on my form with the isNAN result which I can interpret in the remaining fpl.
However, unless there are any potential gotcha's, I'll probably go with Jon's single line of code from fpl. I hadn't realised you could call javaMethod's this way from fpl.
Every day's a learning day
I created a JS script with Steve's isNAN code and called it using callscript from my fpl script. This works nicely, setting another field on my form with the isNAN result which I can interpret in the remaining fpl.
However, unless there are any potential gotcha's, I'll probably go with Jon's single line of code from fpl. I hadn't realised you could call javaMethod's this way from fpl.
Every day's a learning day

0 x
--------------------------------------
Jez Hollinshead - Hampshire CC
Jez Hollinshead - Hampshire CC
-
- Ebase User
- Posts: 331
- Joined: Mon Mar 10, 2014 8:34 am
Yes Jez, I didn't know it is possible to call javaMethods within FPL.
That said we've eventually managed to get all form writers onto JS as it is so much more powerful. We've not looked back!
We've still got hundreds of FPL scripts and they still work fine. If we need to tweak an FPL we do, if the FPL needs significant modifications we just port into JS (mostly this is pretty simple).
Another option in FPL (my FPL is pretty rusty now).
There's an FPL function called 'regex' - it's not documented so I assume Ebase supplied it (?)
It returns true, failed or an error message.
That said we've eventually managed to get all form writers onto JS as it is so much more powerful. We've not looked back!
We've still got hundreds of FPL scripts and they still work fine. If we need to tweak an FPL we do, if the FPL needs significant modifications we just port into JS (mostly this is pretty simple).
Another option in FPL (my FPL is pretty rusty now).
There's an FPL function called 'regex' - it's not documented so I assume Ebase supplied it (?)
Code: Select all
char chk = VALUETOCHECK;
chk = regex('^[0-9]*$',chk);
0 x
Who is online
Users browsing this forum: No registered users and 18 guests