问题描述:

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?

相关阅读:
Top