简体   繁体   中英

Argument error: Invalid date for date field coming from jquery

I have the method definition as:

if elem_date > Date.today
return true
else 
return false

when I run this as validation, Im getting Argument error: Invalid date. This worked before moving the system from rails 2.3.5 to rails 2.3.18. Im using Jquery date plugin in the front end for date selection

Looks like there is discrepency in the format the date is getting validated. You can validate the date by explicitly setting the format using

Date::DATE_FORMATS[:default] = "%m/%d/%Y"

This can be replaced by any format you wish before comparing it with todate. This configuration can be moved into your environment file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM