0

I am new to Spring and JavaScript.

I have created a JSP file enter image description here

In my first.js ,I have the following method

function firstmethod()
{
    window.alert("Enter a New Number");
    return true;
}

But the javascript method is not getting executed.I couldn't figure out the reason.Please suggest

The browser console error log is

enter image description here

Console Error log

enter image description here

Vijay Manohar
  • 473
  • 1
  • 7
  • 22

1 Answers1

0

I would first check to see if the file is showing up in your web browser correctly:

Right-click in browser window, choose "View Page Source (if you're using chrome)," navigate to the tag, find the link to your javascript file and click on it. You should see the contents of it display in your window.

If the code looks right, you might have an error in it. The browser developer tools (right-click browser window, select "Inspect Element") will sometimes display those errors in the "Console" tab.

The code seems fine. Here's a snippet for it:

function firstmethod()
{
    alert("Enter a New Number");
    return true;
}
<form name="firstform" method="post" action="first" onsubmit="return firstmethod()">
  <input type="submit" name="button" value="Click" />
</form>