I am using the date picker provided by jQuery UI to select a date range that ends up in a single text input with something like 11/11/2008 - 12/05/2008. What would you recommend as far a validation (jQuery/JavaScript) on the client side as well as code for validation on the server side (ASP.NET/C#) to make sure the user enters valid dates?
我正在使用jQuery UI提供的日期选择器来选择最终在单个文本输入中的日期范围,例如11/11/2008 - 12/05/2008。您建议客户端验证(jQuery / JavaScript)以及服务器端验证代码(ASP.NET / C#)以确保用户输入有效日期?
Note I asked a question on Stack Overflow the other day about how to parse out the two dates using C# if your interested.
注意我前几天就Stack Overflow问了一个关于如何使用C#解析两个日期的问题。
2
CustomValidator. Should be fairly simple to split these into two separate dates, parse each, and compare as necessary to verify the range is correct.
的CustomValidator。将这些日期拆分为两个单独的日期应该相当简单,解析每个日期,并根据需要进行比较以验证范围是否正确。
2
You can compare Dates with javascript fairly easily, just convert inputs to Date objects, and then any comparator would work. I use Date.js, as it has an excellent parser. On the backend, I would assume that you can do the same thing, the key is to convert all your objects to the same type, and one that can be compared to another.
你可以很容易地将日期与javascript进行比较,只需将输入转换为Date对象,然后任何比较器都可以工作。我使用Date.js,因为它有一个很好的解析器。在后端,我会假设您可以做同样的事情,关键是将所有对象转换为相同的类型,以及可以与另一个对象进行比较的对象。
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2008/11/25/d3542e0c3c0654c245941ded6b995a79.html。