简体   繁体   English

参数错误:来自jQuery的日期字段的无效日期

[英]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. 在将系统从导轨2.3.5移至导轨2.3.18之前,此方法起作用。 Im using Jquery date plugin in the front end for date selection 我在前端使用Jquery日期插件进行日期选择

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. 该配置可以移到您的环境文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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