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>
3
  • it did worked fine , may be try including the script inside block as : {% block %} <script type="text/javascript"> function getCustomerName() { alert('get customer name called....'); } </script> <!-- rest all goes here .. .... . --> {% endblock %} Commented Nov 26, 2020 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. Commented Nov 26, 2020 at 12:53
  • glad it helped you ... you can refer this post for more :) Commented Nov 27, 2020 at 4:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.