开发者

jQuery Submit Form onChange

I'm looking to automatically submit a form using jQuery when an input is changed.

The input in question is a date picker and I need it to submit once somebody has made a selection.

<form id="select_date" name="select_date" method="POST" action="about.php?date-yes">
<input type="text" id="widgetFieldInput">
<input name="select_date" type="submit" /开发者_Go百科>
</form>

Any help would be amazing!


Use the following jQuery snippet:

$("#widgetFieldInput").change(function() {
     this.form.submit();
});


$(document).ready(function(){
   $('#widgetFieldInput').change(function(){
       $('#select_date').click();
    });
});


If you are using the datepicker from jquery-ui you can use the onSelect event to fire custom code once a date has been picked:

$('you-date-input').datepicker({
   onSelect: function(dateText, inst) { 
      // form submit code
   }
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜