-
JoomGuy
-
-
Offline
-
Moderator
-
-
Joomla Enthusiast, Lover of Cooking
- Posts: 1115
- Thank you received: 195
-
Karma: 64
-
|
OK, so what is the highest and lowest acceptable number?
0,0 is the lowest right?
Would a number such as 100000000000000000000,9 be OK?
|
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
|
-
JoomGuy
-
-
Offline
-
Moderator
-
-
Joomla Enthusiast, Lover of Cooking
- Posts: 1115
- Thank you received: 195
-
Karma: 64
-
|
And would 0,0000000000000000009 be OK?
|
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
|
-
goslingcools
-
-
Offline
-
Senior Member
-
- Posts: 64
- Thank you received: 7
-
Karma: 1
-
|
Sorry,
But the price range will probably be from 0 to 999,99
Both fields should only use 2 digits after the COMMA, so NO 0,000000007
So infact It can be any number between 0 and 1000. With 2 digits after the Comma.
|
|
-
JoomGuy
-
-
Offline
-
Moderator
-
-
Joomla Enthusiast, Lover of Cooking
- Posts: 1115
- Thank you received: 195
-
Karma: 64
-
|
OK so anything between 0,00 and 999,99 is acceptable...
1000,01 is not?
But, you do only want 2 digits past the comma right?
Gez
|
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
|
-
goslingcools
-
-
Offline
-
Senior Member
-
- Posts: 64
- Thank you received: 7
-
Karma: 1
-
|
The max does not matter, I don't want to limit it (only for what is necessary according to the db format)
|
|
-
goslingcools
-
-
Offline
-
Senior Member
-
- Posts: 64
- Thank you received: 7
-
Karma: 1
-
|
Should I use a text field instead of a decimal field and use a custom validation on it?
Hmm... this won't work because the comma validation rule is missing...
|
|
-
JoomGuy
-
-
Offline
-
Moderator
-
-
Joomla Enthusiast, Lover of Cooking
- Posts: 1115
- Thank you received: 195
-
Karma: 64
-
|
Yes,
- use a string field and select custom from the validator.
- type in your max length that includes the comma as a character - so 9 following this example - into the length property of the field
- add a unique and descriptive handler like decimal6comma2 where 6 is the max digits before the comma and 2 is the max digits past the comma.
- Paste this regex in
^(0|[1-9]\d{0,5})?(,\d{1,2})?$
- test it in the Preview and Test field
Currently this will allow:
0,0
0
0,00
0,09
0,99
123456
123456,1
123456,10
123456,99
999999,99
Hope it helps!
Gez
|
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
|
-
goslingcools
-
-
Offline
-
Senior Member
-
- Posts: 64
- Thank you received: 7
-
Karma: 1
-
|
Thanks,
This looks perfect! I'll have a try with it asap.
Let you know how it works out.
Thanks again!
btw. just got a book about reg ex, still need to study it
|
|
-
JoomGuy
-
-
Offline
-
Moderator
-
-
Joomla Enthusiast, Lover of Cooking
- Posts: 1115
- Thank you received: 195
-
Karma: 64
-
|
Hi GC ( @goslingcools )
Have you got it working OK? btw. just got a book about reg ex, still need to study it No book for me but, yes, me too!!! It can pretty involved!
We have an awesome regex'er (@g1smd) who's posts have helped me a lot! Checkout the RegEx section in the forum and post any of your work or queries there. Hopefully, over time we can build a robust base of common (and exceptional) expressions where we can all learn from one another!
Anyway, hope it is working fine however, I'm sure with the help of the posts in regex section and your book you'll be able to adapt it to your needs!
Gez
|
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
|
-
g1smd
-
-
Offline
-
Junior Member
-
-
RegEx fiend!
- Posts: 31
- Thank you received: 26
-
Karma: 6
-
|
^(0|[1-9]\d{0,5})?(,\d{1,2})?$ also allows
,5
,99
blank
Remove the first comma to insist on something before the comma.
|
Last Edit: 18 Nov 2012 17:03 by g1smd.
|
-
JoomGuy
-
-
Offline
-
Moderator
-
-
Joomla Enthusiast, Lover of Cooking
- Posts: 1115
- Thank you received: 195
-
Karma: 64
-
|
g1smd wrote:
^(0|[1-9]\d{0,5})?(,\d{1,2})?$ also allows
,5
,99
blank
Remove the first comma to insist on something before the comma. Hi @g1smd
I believe GC wanted to allow ,0 AND ,01 inputed vals (although, I clearly left them out of the valid list).
blank will be caught by the required attribute being set on the field.
Thanks again for your regex-ninja input!!!
Gez
|
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The following user(s) said Thank You: g1smd
|
-
g1smd
-
-
Offline
-
Junior Member
-
-
RegEx fiend!
- Posts: 31
- Thank you received: 26
-
Karma: 6
-
|
Cool!
Just pointing out a minor change that other people might want to make.
(\,{1,2})? allows for one or two digits if there is a comma, or nothing at all.
(\,{2})? insists on exactly two digits if there is a comma, or nothing at all.
The first part of RegEX writing is defining exactly what you want it to do. That should take longer than writing the actual pattern.
|
The following user(s) said Thank You: JoomGuy
|
|