well
i want to validate the tesxt in a text box in the format(order) of
Quantity,Description,dates
i have wrriten the validation format as
validates_format_of :busage ,
                             :with => /\d,(\w+ \s)\,(\d\d:\d\d:\d\d)/ ,
           :message=>"error of dir"
end
but its still giving error
as its validating date and quantity
but its taking character(\w+) instead of a string  (description)
pls help me out
as whn i put a string in place of description it displays the error
pls help out
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
I think you want: /^\d,[\w\s]+,\d\d:\d\d:\d\d$/ That will validate for: 15,Some product description,12:10:06 On Dec 29, 2:29 pm, Prashant Jadhav <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> well > i want to validate the tesxt in a text box in the format(order) of > Quantity,Description,dates > > i have wrriten the validation format as > validates_format_of :busage , > :with => /\d,(\w+ \s)\,(\d\d:\d\d:\d\d)/ , > :message=>"error of dir" > end > > but its still giving error > as its validating date and quantity > but its taking character(\w+) instead of a string (description) > pls help me out > as whn i put a string in place of description it displays the error > > pls help out > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Jadhav, You better use this pattern: /^\d+,\w[\s\w]*,((?:0?[0-9]|1[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9])$/ It will correctly validate the string: 15,Some product description,12:10:06 For validation purposes you don''t have to define any capturing groups. If you want to extract the quantity, description and time then use the pattern: /^(\d+),(\w[\s\w]*),(((?:0?[0-9]|1[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]))$/ Best regards, Mark -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---