Background

Many times, I have observed that users put their problem on CodeProject forum related to JavaScript. Really, they don't know the exact use of JavaScript. Why we should use it? Where to define it?

In this article, I will explain what is JavaScript, why JavaScript is used, how to use JavaScript
for validation, use of functions and properties and some easy functions
that you can copy and paste it in your code. This resource is entirely
about JavaScript.

Introduction

JavaScript is the most popular scripting language and used in almost all browsers. The primary use of JavaScript is to validate user input. Besides that, JavaScript can be used for designing CSS, data manipulation and many more.

Including JavaScript to Page

JavaScript can be used with HTML, DHTML, XML, XHTML, ASP, JSP, ASPX, PHP, etc. JavaScript is defined in a separate block of HEAD. Let's see the following example, it will give you a clear idea.

Prevent ENTER key on Textbox

Disabled RIGHT click using Javascript

If you need to disabled right click on Textbox / Document use the following function:

function DisableRight()
{
if (event.button == 2)
returnfalse;
}

* for textbox, call the above function on OnCLIENTCLICK event * for document, call the above function on ONCLICK event of BODY

Debugging JavaScript with Visual Studio

You can debug the JavaScript functions, just by adding debugger;
keyword in function. But before start debugging, make sure that your
debugging is enabled for script in Internet Explorer. To check setting,
go to Internet Explorer --> Tools --> Internet Options --> Advanced Tab