<?php
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new;
?>
********out put **********
// <a href='test'>Test</a>
[ add comment ] ( 1 view ) | permalink |




( 2.8 / 33 )<?php
$array = array('S2k', 'Design', 'Delhi');
$join_array = join(",", $array);
print "<pre>";
print_r ($array);
print "</pre>";
echo $join_array;
?>
//*************out put ***********
S2k,Design,Delhi
[ add comment ] | permalink |




( 3 / 20 )<?php
$first = 'my name is rakesh';
$first = ucfirst($first); // Hello world!
echo $first;
?>
***********out put********
My Name is Rakesh
[ add comment ] ( 1 view ) | permalink |




( 3.6 / 28 )<?php
$str = "India is the best";
$str = strtoupper($str);
echo $str;
echo '<br>';
$str1 = "INDIA IS THE BEST";
$str1 = strtolower($str1);
echo $str1;
?>
**********
//output
INDIA IS THE BEST // All string to Uppercase
india is the best All string to Lowercase
[ add comment ] ( 1 view ) | permalink |




( 3 / 20 )<?php
$myhtml="I m "the" <b>best</b> ";
$mydecode= html_entity_decode($myhtml);// out put comes like
echo $myhtml.'<br';
?>
**************Out Put ******
I m "the" <b>best</b>
[ add comment ] ( 1 view ) | permalink |




( 2.8 / 33 )There are two function to remove space from right of the text:
(1) chop(string,"");
(2) rtrim(String,"");
//chop("yourstring ","");
<?php
$before='First ';
echo $before.'Second';
echo '<br>';
$after=chop($before," ");
echo $after.'raj'.'<br>';
?>
********* out put******
Rakesh raj // Before chop()
Rakeshraj // After chop()[ here white space removed from right of the
textx
[ add comment ] ( 1 view ) | permalink |




( 3 / 20 )<SCRIPT TYPE="text/javascript" LANGUAGE=JAVASCRIPT>
function validcheck() {
if (document.frmTest.chk1.checked == false &&
document.frmTest.chk2.checked == false &&
document.frmTest.chk3.checked == false)
{
alert (' Please Choose any one from the options.');
return false;
}
else
{
return true;
}
}
</SCRIPT>
********************
<html>
<body>
<form name="frmTest" onsubmit="return validcheck();" action="">
<input type="checkbox" name="chk1" value="India">India1</p>
<input type="checkbox" name="chk2" value="Pakistan">Pakistan</p>
<input type="checkbox" name="chk3" value="japan">japan</p>
<input type="submit" value="Submit!" />
</form>
</body>
</html>
[ add comment ] ( 1 view ) | permalink |




( 3 / 15 )<script>
function Validation(){
var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
str = document.getElementById('txtemail').value;
if(str.match(emailRegEx)) {
alert(str+' is valid email id.');
return true;
}
else {
alert(str+' is invalid email address.');
return false;
}
}
</script>
************************
<html>
<body>
<form name="frm" method="post" action="#" onsubmit="return Validation();">
Enter your email id:
<input type="text" name="txtemail" id="txtemail" />
<input type="submit" name="submit" value="Check"/>
</form>
</body>
</html>
[ add comment ] ( 1 view ) | permalink |




( 3.8 / 24 )This is very simple way to validate radio button through Javascript in HTML Form.
<script type="text/javascript">
function validate_form (str) {
valid = true;
if (
(document.frmSample.rdo1[0].checked == false )
&& ( document.frmSample.rdo1[1].checked == false ) )
{
alert ( "Please choose your option" );
valid = false;
}
else if( document.frmSample.rdo1[0].checked == true ) {
alert ( document.frmSample.rdo1[0].value );
valid=true;
}
else if( document.frmSample.rdo1[1].checked == true ) {
alert ( document.frmSample.rdo1[1].value );
valid=true;
}
}
</script>
***************************
<html>
<body>
<form name="frmSample" action="#" method="post" onSubmit="return validate_form();">
<input type="radio" name="rdo1" value="Male" />Male<br />
<input type="radio" name="rdo1" value="Female" />Female<br />
<input type="button" name="submit" value="Check" onClick="return validate_form();"/>
</form>
</body>
</html>
[ add comment ] ( 1 view ) | permalink |




( 3 / 15 )This code display a textbox that accept only numeric value.
<script type="text/javascript">
function Validation(){
var a=document.getElementById('MyTextBox').value;
var regex1=/^[0-9]*$/;
if(regex1.test(a)== false){
alert('Please enter only Numeric value ');
MyTextBox.focus();
return false;
}
else {
alert('Accepted ');
}
}
</script>
****************************
<html>
<body>
<INPUT name="MyTextBox" type="text" id="MyTextBox">
<INPUT onClick="Validation();" id=Button1 type=button value="Test
Number!" name=btnTest>
</body>
</html>
[ add comment ] | permalink |




( 3 / 15 )
Calendar



