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">
	<noscript>
		<input name="js_enabled" type="hidden" value="1">
	</noscript>
	<input id="email" name="email" size="30" class="required email" ><br>
	<input id="submit_data" value="Submit" type="submit"><br>
</form>

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

<?php

// Check if Javascript is enabel from hidden value in <noscript></noscript>
$browser_check = 0;
if(isset($_POST['js_enabled']))
	$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)
Tags: , ,
Category: Enterprise Linux, Technical Solutions
This entry was posted Thursday, 3 September, 2009 at 3:58 pm
You can follow any responses to this entry via RSS.

Leave a Reply

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

No comments yet