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
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 J. [email protected]
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