browse by category or date

JavaScript has become more and more important part of Web Application. Often, it does a crucial role such as doing the data verification check on the client side. Quite often also, we use JavaScript to limit the behavior of a field to suit our need. For example, making a textbox to only accept numbers.

But all this fancy ideas will not work if the JavaScript is disabled. To check wheter your user have their Javascript enabled in their environment, add the following snippets into your form:

<script type="text/javascript">
function checkJavascript()
    var obj = document.getElementById('javascriptCheck');
    obj.value ="1";
<body onload="checkJavascript();">
   <form><input type="hidden" id="javascriptCheck" name="javascriptCheck" value="0" />
       <!-- put the remaining form in inputs here -->


On the server you will need to check is the ‘javascriptCheck’ variable’s value is ‘1’. If it is, it means Javascript is enabled.

GD Star Rating

About Hardono

Hi, I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

2 comments so far

Add Your Comment
  1. The much more appropriate DOM-style access would be:

    document.forms[’form_name’].elements[’javascriptCheck’].value = 1;

    Then leave the input as:
    <input type=”hidden” name=”javascriptCheck” value=”0″>

    Sorry about that! Stupid me of me to think markup was enabled on your blog.

  2. A very good suggestion. Looking at my code again, it did not even check for null value. Although I could say that since this is code into our own form, the element should be there.

    But always checking for null value is actually a good habit.