I want to call the javaScript function defined inside the same template in Django. How can I do it?
{% extends 'base.html' %}
{% block content %}
{% if error %}
showAlert()
{% endif %}
<script> function showAlert() {alert ("Please select at least one option");}</script>
{% endblock %}
I want to call showAlert() if there is error present. I have handled the error in the view. I do not a method about how to call the function here? It is showing the function name.
alertis available in the browser in JavaScript.<script>blocks.<script> showAlert() </script>