0

I am trying to run a javascript function when control comes out of a field(AWSID). Getting the following error: Uncaught ReferenceError: getCustomerName is not defined at HTMLInputElement.onblur (ipwhitelistindex:12) onblur @ ipwhitelistindex:12

Please help me out.

 {% extends 'base.html' %}
<html>
<body>
    <script type ="text/javascript">
      function getCustomerName() {
            alert('get customer name called....');
       }
    </script>
{% block content %}
    <h1>IP Whitelisting</h1>
    <form name = "ipwhitelistindex" action = 'ipwhitelisting' method = "post">
        {% csrf_token %}
        <center>
            <table>
        <tr><td>Enter AWS Account Id </td><td>:</td><td><input type = 'text' name = AWSID onblur="getCustomerName()"></td></tr>
        <tr><td>Customer Name </td><td>:</td><td><input type = 'text' name = CUSTNAME style = "background-color : lightgrey" readonly></td></tr>
        <tr><td>Enter list of IPS seperated with(,) </td><td>:</td><td><input type = 'text' name = IPS></td></tr>
        <tr><td>Enter description </td><td>:</td><td><input type = 'text' name = DESC></td></tr>
            </table><br>
            <input type = 'submit' value = 'submit'>
        </center>
    </form>
{% endblock %}
</body>
</html>
  • it did worked fine , may be try including the script inside block as : `{% block %} {% endblock %}` – KcH Nov 26 '20 at 12:26
  • Thank you @Codenewbie. it worked fine after including the script inside the block but what's the reason, I don't know why it did not work when it is outside the block. – Harikrishna Gannu Nov 26 '20 at 12:53
  • glad it helped you ... [you can refer this post for more :)](https://stackoverflow.com/questions/3412275/loading-external-script-with-jinja2-template-directive) – KcH Nov 27 '20 at 04:39

0 Answers0