forms.py
class SearchFilterForm(Form):
fromdate = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'dd/mm/yy','class':'datefield','readonly':'readonly'}))
todate = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'dd/mm/yy','class':'datefield','readonly':'readonly'}))
javascript:
function comparedate(){
var fromdate = document.getElementById("id_fromdate").value;
var todate = document.getElementById("id_todate").value;
if(fromdate<todate){
{
$("#error-warning").show();
$("#error-warning").text("Please correct the To date");
return false;
}
}
template.html
<button type="submit" name="filter" onclick="comparedate()">Go <img src="/static/images/button-icon-ir-fwd.png" alt="" height="17" width="8"></button><div id="error-warning" style="display:none" class="errorlist">Please correct the To date</div>
This code is for validating the from date and to date.Validation is happening but after validation the form gets submit again.This is used in search report function,so if the entered to date is less than from date it is showing error message and it go's for search ,which should not happen.
Can any one tell me what would be the problem