This implies a problem when there are other languages that would better a particular task. Let’s review what cases it is better to use Javascript and which not.
When NOT to use javascript
With Javascript can validate forms. You can create a great user experience using this method, but it would be foolish not to validate all input again with a server side language before processing. If you want to choose one or the other, use the server side. If you can be in another language, use the other language.
Inserting
If you need to load a block of dynamic navigation and you can not create a file that can be included in the server side of the homepage, you can use jQuery load function to call the block. Works great unless you can not or want to use JavaScript. If you can be in another language, use the other language.
Similarly, the whole concept of AJAX is generally considered a hack. It is a way of simulating two-way communication technology built for a one-sided delivery. When there is something new that fits more naturally bidirectional communication of browser-server, Ajax goes away. If you can be in another language, use the other language.
Giving style
JavaScript is able to apply style to elements of a page. That is also the job of CSS. Too much information makes the JavaScript way harder to read, and updates more difficult to track style. If you can be in another language, use the other language.
One of the major reasons which JavaScript libraries are popular is because they open the door to a wealth of design possibilities. You can do fades in and out, animating the sizes and positions and more. But these things are usually related to the design rather than functionality. As CSS is more appropriate for these things. If you can be in another language, use the other language.
When to use
Enough cases of when to use it. There are many circumstances in which use of Javascript is the only option. For example, in the events. Javascript is the only language available to make your web site to communicate with the browser and observe events such as clicks, double clicks, mouse outbreaks, keystrokes … and the list goes on. If you need access to these events, javascript is your territory.