Friday, 27 April 2012

how to validate multiple select box with jquery?

$("#form").validate({
rules:{
"select_esp[]": "required"
},
messages:{
"select_esp[]": "Select this"
}
});

 

Saturday, 14 April 2012

How to enable/disable element in Javascript

If u want to enable or disable any HTML element using javascript in asp.net/php u can use the following code,

document.getelementbyid('nm').disabled='disabled' ;


and the below code will enable the element,

document.getelementbyid('nm').disabled='';

Tuesday, 3 April 2012

how to make captcha in php?

Captcha Code:

<?php
session_start();

$num='';

$string = "abcdefghijklmnopqrstuvwxyz0123456789";
for($i=0;$i<7;$i++){
$num1=rand(0,35);
$num .= $string{$num1};
}

$_SESSION["num1"]=$num;

$img=imagecreatefrompng('captcha.png');
$color=imagecolorallocate($img,255,255,255);
$color1=imagecolorallocate($img,0,0,0);
imagestring($img,9,10,3,$num,30);
$fontsize=20;
$fontcolor = imagecolorallocate($img, 0, 0, 0);
$x = 0;
$y = $fontsize;

header('Content-type : image/png');
imagepng($img);
imagedestroy($img);

?>

How to use in php?

<img id="cap" style="margin-left: 15px;" src="comman/captcha.php" alt="" />

How to refresh captcha?

Call the below function  onclick

<script >
function captcha()
{
document.getElementById('cap').src = document.getElementById('cap').src+ '?';
}
</script>

Save as captcha.png file

Monday, 2 April 2012

how to check path of ffmpeg or mencoder in linux in php?

<?php
$output = shell_exec('whereis ffmpeg');
echo "<pre>".$output."</pre>";
echo "";

$output = shell_exec('whereis mencoder');
echo "<pre>".$output."</pre>";
echo "";
?>

Output in browser :

Monday, 26 March 2012

How to launch jQuery Fancybox on page load?

//first include fancybox javascript file and jquery javascript file.

<script type="text/javascript">

jQuery(document).ready(function() {
$("a#various2").trigger('click');
});
</script>

Friday, 23 March 2012

how to remove any character using javascript?

I am removing only " - (dash), . (dot), (space) in this exmple.

function dotrm(cit)
{
var cl=cit.length;
var ch=cit;
for(l=0;l<=cl;l++)
{
if(cit[l] == '.' || cit[l] == ' ' || cit[l]=='-')
{
ch=cit.replace(cit[l],'');
}
}
document.getElementById("city").value=ch;
}