[Fixed]-Checking inputs of form in django before submit

1👍

As one option you can use jQuery validation and set the required fields like so:

$(document).ready(function(){
    $("#your_form_id").validate({
       rules :{
            your_field : {
            required : true
            }
            .....
       },
       messages :{
            your_field : {
            required : 'your_field is required'
            }
            .....
       }
    });
});

Edit: Just saw you said not to send to view. So, ignore this but I’ll leave it for future reference on the off chance that it’s useful.

Preferably, you could turn this into a form import it from forms.py and then send it to your view. You could then just set which fields are required.

Leave a comment