Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC:

Re: qv:custom rule not found - decimal_comma 18 Nov 2012 12:28 #5456

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
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!!!

Please Log in or Create an account to join the conversation.

Re: qv:custom rule not found - decimal_comma 18 Nov 2012 12:29 #5457

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
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!!!

Please Log in or Create an account to join the conversation.

Re: qv:custom rule not found - decimal_comma 18 Nov 2012 12:29 #5458

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.

Please Log in or Create an account to join the conversation.

Last edit: by goslingcools.

Re: qv:custom rule not found - decimal_comma 18 Nov 2012 12:32 #5459

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
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!!!

Please Log in or Create an account to join the conversation.

Re: qv:custom rule not found - decimal_comma 18 Nov 2012 12:34 #5460

The max does not matter, I don't want to limit it (only for what is necessary according to the db format)

Please Log in or Create an account to join the conversation.

Re: qv:custom rule not found - decimal_comma 18 Nov 2012 12:36 #5461

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...

Please Log in or Create an account to join the conversation.

Last edit: by goslingcools.

Re: qv:custom rule not found - decimal_comma 18 Nov 2012 13:22 #5462

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
Yes,
  1. use a string field and select custom from the validator.
  2. type in your max length that includes the comma as a character - so 9 following this example - into the length property of the field
  3. 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.
  4. Paste this regex in
    ^(0|[1-9]\d{0,5})?(,\d{1,2})?$
  5. 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!!!
The following user(s) said Thank You: goslingcools

Please Log in or Create an account to join the conversation.

Re: qv:custom rule not found - decimal_comma 18 Nov 2012 13:33 #5463

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 :-)

Please Log in or Create an account to join the conversation.

Last edit: by goslingcools.

Re: qv:custom rule not found - decimal_comma 18 Nov 2012 15:05 #5465

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
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!!! :sick: 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!!!

Please Log in or Create an account to join the conversation.

Re: qv:custom rule not found - decimal_comma 18 Nov 2012 16:59 #5468

  • g1smd
  • g1smd's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • RegEx fiend!
  • Posts: 31
  • Thank you received: 26
^(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. :cheer:
Online since 1996.

Please Log in or Create an account to join the conversation.

Last edit: by g1smd.

Re: qv:custom rule not found - decimal_comma 18 Nov 2012 17:12 #5469

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195

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. :cheer:

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

Please Log in or Create an account to join the conversation.

Re: qv:custom rule not found - decimal_comma 18 Nov 2012 17:19 #5470

  • g1smd
  • g1smd's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • RegEx fiend!
  • Posts: 31
  • Thank you received: 26
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.
Online since 1996.
The following user(s) said Thank You: JoomGuy

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Time to create page: 0.085 seconds

  Excellent Tool ! This tool will save you a lot of time writing the same old structure. I've used others but this is really nice for a quick start. Makes a 3 hour task a 15 minute one. Thanks for this extension
dickrundell (JED)
         

Get Started