当前位置: 动力学知识库 > 问答 > 编程问答 >

jquery - Javascript requires an extra refresh once data is submitted

问题描述:

When I submit a form with invalid two form data I need to click twice the submit button to display javascript alert. Then after inputting valid data I need to click twice to make not to display javascript alert

$(document).ready(function () {

$('.dateinput').datepicker();

$("#daterangeresult").click(function(){

var start_date = "{{ form.data.start_date }}";

var end_date = "{{ form.data.end_date }}";

if (Date.parse(start_date) >= Date.parse(end_date)) {

alert("Enter start date less than end date");

}

});

});

My html file is

<form action="" method="POST"> {% csrf_token %}

Start Date: {{ form.start_date }}&nbsp;&nbsp; End Date:{{ form.end_date }}<br/>

<input type = "submit" value = "See Results" id = "daterangeresult"></form>

what is problem here?

分享给朋友:
您可能感兴趣的文章:
随机阅读: