How to check if Javascript is enabled on the client side using php


You might be using validations for your form on client side using Javascript. It may arise that client side Javascript is disabled, given this scenario your validations will go for a toss.

You can check in your php if Javascript is enabled on client side using the following method.

Add a hidden input in your form in the <noscript> tag. The contents of noscript tag are rendered on a browser with Javascript disabled:

<form id="" action="" method="post">
		<input name="js_enabled" type="hidden" value="1">
	<input id="email" name="email" size="30" class="required email" ><br>
	<input id="submit_data" value="Submit" type="submit"><br>

Now the following will be the php code to check whether Javacript is enabled:


// Check if Javascript is enabel from hidden value in <noscript></noscript>
$browser_check = 0;
	$browser_check = $_POST['js_enabled'];

if ($browser_check == 1) {
	echo ' Javascript is disabled on your system';


This is useful if you use ajax submission of form. Say to check if email exists and display the same in error div. Or maybe other scenarios that may suit your requirements.

(Visited 1 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *

No comments yet