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

TOPIC:

Re: DECIMAL FLD DONT VALIDATE IF NOT FOCUSOUT B4 SAVE 23 Nov 2012 07:58 #5627

  • g1smd
  • g1smd's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • RegEx fiend!
  • Posts: 31
  • Thank you received: 26
//decima8to2
^(0(\.(0[1-9]|[1-9]\d{0,1}))|([1-9]\d{0,5}(\.\d{0,2})?))?$

This allows 0 values only when followed .01 or greater or any numbers beginning with 1-9 up to 6 digits total followed by optional decimal point + 1 or 2 digits

There's a slight difference between your code and the description.
(\.\d{0,2})?
allows optional decimal point + 0 or 1 or 2 digits so 40.00 could be entered as 40. or as 40 here.

The final ?$ also allows blank input. There's also a set of unnecessary brackets.

Suggest
^( 0(\.(0[1-9]|[1-9]\d{0,1})) | [1-9]\d{0,5}(\.\d{0,2})? )$
or
^( 0(\.(0[1-9]|[1-9]\d{0,1})) | [1-9]\d{0,5}(\.\d{1,2})? )$

If you want to allow people to type .75 instead of 0.75 try:
^( 0?(\.(0[1-9]|[1-9]\d{0,1})) | [1-9]\d{0,5}(\.\d{1,2})? )$

Remove spaces before using.

Regular expressions give you an infinite number of very fine grained possibilities. :)
Online since 1996.
The following user(s) said Thank You: JoomGuy

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

Last edit: by g1smd.

Re: DECIMAL FLD DONT VALIDATE IF NOT FOCUSOUT B4 SAVE 25 Nov 2012 11:05 #5638

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

I thought I'd already replied to this but obviously didn't.

The first regex is the cook default, the one I wanted to replace with the longer one which I believe does fit the requirements I specified doesn't it?

Thanks for pointing out the additional brackets! Will remove although the required parameter on the field prevents the user leaving blank.

Thanks again,

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: DECIMAL FLD DONT VALIDATE IF NOT FOCUSOUT B4 SAVE 30 Nov 2012 00:02 #5691

  • g1smd
  • g1smd's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • RegEx fiend!
  • Posts: 31
  • Thank you received: 26
^([1-9]\d{0,1}(\.\d{1,2})?|0\.[1-9]\d{0,1})$
\d{0,1}
simplifies to
\d?
:)
^([1-9]\d?(\.\d{1,2})?|0\.[1-9]\d?)$
Online since 1996.
The following user(s) said Thank You: JoomGuy

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

Last edit: by g1smd.
  • Page:
  • 1
Time to create page: 0.060 seconds

  I found "cook" two days ago. Played around with it for a day and then within a day got rid of two legacy applications in IBM Lotus Domino Notes and replaced them with "cook". It was really easy. A piece of cake. Actually it was even easier than cooking. Cooking involves more work than developing with "cook". What can I say about "cook"? Great application great price for what it delivers great forum with a lot of information and fast responses active and friendly community fast forward moving development cycle So what should I say "Monsieur Le Cook"? Keep the good work going it will lead to success. Having become a paying member in the words of Edith Piaf may I say ..... non rien de rien ... je ne regrette rien. Vive La France.
FK (JED)
         

Get Started