我们如何检测隐藏的表单字段何时动态更改?如果已更改,则显示警告?
JQuery UI(DatePicker)用于更改隐藏的表单字段。
$("#datepicker").datepicker({altField: "#alternate", altFormat: "yymmdd"}).$('#alternate').trigger('change');
<input name="textbox" id="alternate" type="hidden" size="30"
onchange="alert('changed')" />
答案 0 :(得分:0)
$('#alternate').change(function(){
window.alert('Change has happened. Ya dig?');
});
答案 1 :(得分:0)
在StackOverflow.com上的两个类似问题的帮助下解决了这个问题
<input name="textbox" id="alternate" type="hidden" size="30"
onchange="alert('changed')" />
<script>
$(function() {
$("#myDatePicker").datepicker({
// The hidden field to receive the date
altField: "#alternate",
// The format for the date
altFormat: "yymmdd",
onSelect: function (date) {
// trigger the .change() event
$('#alternate').trigger('change');
}
})
});
</script>