JQuery Datepicker中的onSelect事件没有'似乎没有开火
onSelect event in JQuery Datepicker doesn't seem to fire
这可能只是一个简单的错误,但我花了最后3个小时试图弄清楚,但没有成功。
我最终想做的是使用输入的日期,并将其与截止日期进行比较,以判断提交是否为时已晚。然而,目前,为了简化起见,我只想告诉我,日期已经改变,但没有成功。我哪里错了?
$("#id_submission_date").datepicker({
onSelect: function(dateText) {
$("#late_submission_warning").text("Date selected");
}
});
以下是页面中的(缩短的)HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title> Feedback for Student, Test</title>
<meta name="description" content="">
<link href="/static/css/bootstrap.css" rel="stylesheet" media="screen">
<link href="/static/css/jquery.qtip.min.css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
.sidebar-nav{
padding: 9px 0;
}
</style>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
...
</nav>
<form action="" method="post" accept-charset="utf-8" role="form">
<input type='hidden' name='csrfmiddlewaretoken' value='...' />
<div class="container">
<h1>European Law (2013/2014): Essay</h1>
<h2>Test Student</h2>
...
<label for="submission_date">Submission Date</label>
<input class="form-control" data-date-format="dd/mm/yyyy" id="id_submission_date" name="submission_date" type="text" value="13/04/2015" />
<select class="form-control" id="id_category_mark_2" name="category_mark_2">
<option value="" selected="selected">---------</option>
<option value="39">0 - 39 %</option>
<option value="49">40 - 49 %</option>
<option value="59">50 - 59 %</option>
<option value="69">60 - 69 %</option>
<option value="79">70 - 79 %</option>
<option value="80">80 or more</option>
</select>
<div id="late_submission_warning"></div>
<h4>General Comments</h4>
<textarea class="form-control" cols="40" id="id_comments" name="comments" rows="10">
</textarea>
<br><br>
<input type = "submit" value="Save" class="btn btn-default">
</form>
</div>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.js"></script>
<script src="/static/js/bootstrap-datepicker.js"></script>
<script src="/static/js/jquery.tablesorter.js"></script>
<script src="/static/js/jquery.metadata.js"></script>
<script src="/static/js/jquery.validate.min.js"></script>
<script src="/static/js/bootbox.min.js"></script>
<script src="/static/js/jquery.qtip.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#sortable_table").tablesorter({
sortList: [[0,0],[1,0]]
});
}
);
</script>
<script type="text/javascript">
$(document).ready(function(){
$("#id_submission_date").datepicker({
onSelect: function(dateText) {
console.log(dateText);
}
});
$("#category_2").qtip({
content: {
text: '80+ very full and perceptive awareness of issues, with original critical and analytical assessment of the issues and an excellent grasp of their wider significance.<br />70+ full and perceptive awareness of issues and a clear grasp of their wider significance.<br />60 - 69 adequate awareness of issues and a serious understanding of their wider significance.<br />50 - 59 some awareness of issues and their wider significance.<br />40 - 49 limited awareness of issues and their wider significance.<br />Below 40 very limited awareness of issues and of their wider significance.'
}
});
});
</script>
</body>
</html>
您的JavaScript似乎有问题,您必须查看控制台消息才能发现问题所在。
无论如何,在发表任何评论或完整的解决方案之前,我希望看到完整的HTML和代码。但是,根据您的要求,为了保持简单,并确保正确记录更改的日期,我们必须遵循以下方法。
$("#id_submission_date").datepicker({
onSelect: function(dateText) {
console.log(dateText);
}
});
此处的"dateText"应包含所需的选定日期。请检查您的浏览器控制台。但是,如果出现错误,将显示正确的错误。
一旦确定了合适的日期,就可以进行比较
如果出现错误,请在这里发布错误消息,我们可以讨论更多。
相关文章:
- 点击不'似乎没有开火
- 强制 $scope.$watch 只开火一次
- extjs关闭事件不'不要开火
- Safari扩展中的注入脚本;不要在Youtube上开火
- KeyDown不会'按住时不能连续开火
- Raphael JS事件未开火
- JQuery窗口调整大小;不要开火
- 谷歌地球回调未开火
- 在控制器中创建StandardListItem并在赢得的项目上按下事件'不要开火
- 提高敲除自定义绑定的效率(经常开火)
- 流星:onhashchange不会开火
- Onicecandidate 不会在第二台 PC 上开火
- 如果 onclick 和 onselect 中的语句在 ASP.NET 不起作用
- jQuery Datepicker onSelect event get class
- JQuery日期选择器-onSelect日期格式
- 下拉框-onchange和onselect
- Noob javascript,为什么这个开火是加载的
- $ionicPlatform.准备不开火
- 在指令不开火中取消OnSelect
- JQuery Datepicker中的onSelect事件没有'似乎没有开火