One of my unique functionalities is that I contain a radio button in my form. If the user clicks "Yes," an error message will be displayed on the screen indicating that this is not the correct place to submit data, and suggesting that they visit another website.
However, if the user clicks "No," all other fields in the form should become visible and mandatory.
One issue I currently face is that when the user clicks "No" and attempts to submit the form without filling in all the required fields, the form gets reloaded and the fields are hidden once again. While the data is not saved in the database, upon clicking "No" again, the fields are displayed with errors highlighted.
The main concern is that when the user clicks "No" and all fields are displayed, I do not want them to be hidden again until the form is successfully submitted or the user clicks "Yes." I am seeking a solution that will only reload the form when all fields are correctly filled and submitted to the database.
Below, I have included the code I have written so far for better understanding:
1) models.py
// Code for models.py
2) forms.py
// Code for forms.py
3) Javascript / jQuery logic
// Code for Javascript / jQuery logic
Any assistance or advice on this matter would be greatly appreciated!