I have a django app where user can submit a form .I have put this form inside a div (say of id='mydiv_id') which is initially invisible(by css display:none).When a user want to enter the input ,he clicks a show button on the page ,and a javascript makes the div visible by making display:block.
The fields in the form have {{myform.myfield.errors}} so that a ul class="errorlist" will be created if validation fails.
I want to keep the form visible by running another javascript if the form validation fails.The body of javascript will be just $('#mydiv_id').show();
But how should I make this run? How do you tell the javascript that django form validation failed without doing the validation inside the javascript?
I think I need to put the following in javascript body..Other than that I can't figure out how to tell it that form submission failed.
$(document).ready(function(){
..
});