开发者

javascript form validation for date & Time

开发者 https://www.devze.com 2023-02-18 05:37 出处:网络
I am writing a javascript to validate Date&time based on the two Dropdowns selected Based on the dropdown change the validation has to be开发者_如何学编程 changed on Date&Time field

I am writing a javascript to validate Date&time based on the two Dropdowns selected

Based on the dropdown change the validation has to be开发者_如何学编程 changed on Date&Time field

I am looking for the validation popup some thing like:

  1. Entered Date&Time should be on or before 1 AM (Midnight) same day


I'm sure that a framework would help immensely (and I'm sure you'll get lot of suggestions to move to one) but if you're just looking for better Date handling you might want to look at my DP_DateExtensions component.

It'll allow you to very simply parse dates (create date objects from your drop-down field values using the Date.parseFormat() method) and then do date math and comparisons on them (in your case using date.compare() to compare the entered date to your target date).

You can then use the timeFormat() and dateFormat() methods to display date/times exactly as you want.

The component's old... but well seasoned and, at least to me, insanely useful.

0

精彩评论

暂无评论...
验证码 换一张
取 消