使用datepicker在文本框中进行验证

时间:2022-11-29 16:04:45

I have three textboxes, box1-filled by user1 box2-filled by user2 box3-filled by user3

我有三个文本框,box1-user由user1 box2-filled由user2 box3-filled由user3填充

I have also a default value for these three boxes. 1.Now when box1 is selected user1 cannot input dates before the default date and it should not be allowed to select dates more than in box2(if not blank,otherwise default date is considered). 2.user2 can enter dates in the range of box1 and box2. if these boxes are empty,default will be considered. 3.user3 can enter date after the dates in box2.

我还有这三个框的默认值。 1.现在当选择box1时,user1不能在默认日期之前输入日期,并且不应该允许选择多于box2的日期(如果不是空白,则考虑默认日期)。 2.user2可以输入box1和box2范围内的日期。如果这些框为空,则将考虑默认值。 3.user3可以在box2中的日期之后输入日期。

pls can you suggest some solution,as i am new to this technology. thnx in advance

你可以建议一些解决方案,因为我是这项技术的新手。 thnx提前

2 个解决方案

#1


Given you're scenario and desire to use jQuery to implement this behavior, how about this:

鉴于您的情况和使用jQuery实现此行为的愿望,请执行以下操作:

Wire up an onchange event handler using jQuery to each textbox and then when the value changes, perform your validation and take the appropriate steps.

使用jQuery将onchange事件处理程序连接到每个文本框,然后在值更改时,执行验证并执行适当的步骤。

#2


You should look at the beforeShow function of the datepicker (take a look under the options tab in the link)-

你应该看看datepicker的beforeShow函数(看看链接中的选项选项卡) -

Can be a function that takes an input field and current datepicker instance and returns a settings (anonymous) object to update the date picker with. It is called just before the datepicker is displayed.

可以是一个函数,它接受一个输入字段和当前的datepicker实例,并返回一个设置(匿名)对象来更新日期选择器。它在显示datepicker之前调用。

I was looking to do some similar range/date restrictions with just two input controls in this question, to give you an idea of how you can work with the function.

我想在这个问题中只用两个输入控件做一些类似的范围/日期限制,让你了解如何使用这个功能。

#1


Given you're scenario and desire to use jQuery to implement this behavior, how about this:

鉴于您的情况和使用jQuery实现此行为的愿望,请执行以下操作:

Wire up an onchange event handler using jQuery to each textbox and then when the value changes, perform your validation and take the appropriate steps.

使用jQuery将onchange事件处理程序连接到每个文本框,然后在值更改时,执行验证并执行适当的步骤。

#2


You should look at the beforeShow function of the datepicker (take a look under the options tab in the link)-

你应该看看datepicker的beforeShow函数(看看链接中的选项选项卡) -

Can be a function that takes an input field and current datepicker instance and returns a settings (anonymous) object to update the date picker with. It is called just before the datepicker is displayed.

可以是一个函数,它接受一个输入字段和当前的datepicker实例,并返回一个设置(匿名)对象来更新日期选择器。它在显示datepicker之前调用。

I was looking to do some similar range/date restrictions with just two input controls in this question, to give you an idea of how you can work with the function.

我想在这个问题中只用两个输入控件做一些类似的范围/日期限制,让你了解如何使用这个功能。