When your JavaScript code is “not being called” it is usually because there is something wrong with it. When any line of the JavaScript throws an exception, and remember this JavaScript code is not compiled but interpreted and executed immediately at runtime, I am guessing every bit of code below it is simply skipped and the codebehind in the back end is automatically executed. To debug it you need to open the developer’s console in your browser’s debugger. For me this was Chrome, so go to: Customise and Control Google Chrome/More tools/Developer tools (or Ctrl + Shift + i), then go to Console. Now run your code from within Visual Studio and observe what exception or error is thrown from within the JavaScript code. For me this error was “JobSeekerRegistration.aspx:100 Uncaught TypeError: document.getElementsById is not a function”. All I did then was change the document.getElementsById in two lines of my code to document.getElementsByName and voila it worked. A special thank you to Aristos but my answer is the best.
solved Why is my JavaScript function apparently not being called?