禁用选择jQuery Datepicker字段? [英] Disable selection jQuery Datepicker field?
问题描述
到目前为止,如果第一个发生在第二个之前,我已经能够选择第二个提醒,但是我无法弄清楚如何使datepicker保持打开状态,以便用户可以选择别的东西
以下是我到目前为止的代码:
脚本>
$(document).ready(function(){
$(。datepicker_start)。datepicker({
maxDate:'+ 0d',
onSelect:function(dateText ,
$ b}
});
$(。datepicker_to)。datepicker({
maxDate:'+ 0d',
onSelect:function(dateText,inst){
var startDate = $('。datepicker_start')val();
$(this).attr('value',dateText)
if (startDate> dateText){
alert('not cool!');
}
}
});
});
< / script>
有谁知道我会怎么做?我尝试返回false,但仍然将不正确的日期推送到字段:(
$(function(){
$(#from).datepicker({
defaultDate:+ 1w,
changeMonth:true,
numberOfMonths:3,
onSelect:function(selectedDate){
$(#to).datepicker(option,minDate,selectedDate);
}
});
$(#to).datepicker({
defaultDate:+ 1w,
changeMonth:true,
numberOfMonths:3,
onSelect:function(selectedDate){
$(#from).datepicker(option,maxDate,selectedDate);
}
});
});
From: http://jqueryui.com/demos/datepicker/date-range.html
I'm using jQuery UI Datepicker to make a two field submission form. I want the user to create a range and submit it to see results. However, they obviously cannot pick a start date that happens more recently than an end date (you can't see a range starting today and going to yesterday). As of now, I've been able to put an alert on selection of the second one if the first one happened before it, but I can't figure out how to have the datepicker stay open so the user can select something else.
Here is the code I have so far:
<script>
$(document).ready(function() {
$(".datepicker_start").datepicker({
maxDate: '+0d',
onSelect: function(dateText, inst) {
}
});
$(".datepicker_to").datepicker({
maxDate: '+0d',
onSelect: function(dateText, inst) {
var startDate = $('.datepicker_start').val();
$(this).attr('value', dateText)
if (startDate > dateText) {
alert('not cool!');
}
}
});
});
</script>
Does anyone know how I'd do this? I tried returning false but it still pushes the incorrect date to the field :(
$(function() {
$( "#from" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onSelect: function( selectedDate ) {
$( "#to" ).datepicker( "option", "minDate", selectedDate );
}
});
$( "#to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onSelect: function( selectedDate ) {
$( "#from" ).datepicker( "option", "maxDate", selectedDate);
}
});
});
From: http://jqueryui.com/demos/datepicker/date-range.html
这篇关于禁用选择jQuery Datepicker字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!