Friday, January 4, 2008

phone no validation

function validatePhone(obj,msg)
{
var validNum =/^[\(]?(\d{0,3})[\)]?[\s]?[\-]?(\d{3})[\s]?[\-]?(\d{4})[\s]?[x]?(\d*)$/;
if (validNum.test(obj.value) == false)
{
alert(msg);
obj.focus();
obj.select();
return false;
}
return true;
}

Sunday, August 12, 2007

Creating a popup

Use the following script



Then, you link to it by:

Link to popup

Friday, July 20, 2007

How to Make the Background of a Div Transparent?

In the HTML code, give a unique ID to the div with transparent background such as below:



In the stylesheet, define the style for this ID such as below:

#transparency {filter: alpha(opacity=55); -moz-opacity: .55; background-color:#EEE; position:absolute; top:450px; left:110px; }


filter property works in internet explorer and -moz is for firefox .

Thursday, July 12, 2007

Php Server side security using preg_match.

To avoid the cross side scripting or make site safe from hacker attacks one need to perform data validation before allowed data insertion into database . We can achieve this using php preg_match which check data format to see whether it is in valid state or not. The following code snippet is standard validation example

function isHackerSafeUsername($Subject)
{
if( preg_match("/^[a-zA-Z][\w\._]*[a-zA-Z0-9]$/",$Subject)) return true;
else return false;
}
function isHackerSafePassword($Subject)
{
if( preg_match("/[^a-zA-Z0-9@._'-]/",$Subject)) return false;
else return true;
}

function isHackerSafeName($Subject)
{
if( preg_match("/^[a-zA-Z]{1,}$/",$Subject)) return true;
else return false;
}
function isHackerSafeEmail($Subject)
{
if( preg_match("/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*
[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]/",$Subject)) return true;
else return false;
}
function isHackerSafeLan($Subject)
{
if( preg_match("/^[a-zA-Z]{1}$/",$Subject)) return true;
else return false;
}
function isHackerSafeNumber($Subject)
{
if( preg_match("/^[0-9]{1,15}$/",$Subject)) return true;
else return false;
}

function isHackerSafeAddress($Subject)
{
if( preg_match("/^[a-zA-Z0-9\s,]{1,}$/",$Subject)) return true;
else return false;
}


function isHackerSafeTitle($Subject)
{
if( preg_match("/^[a-zA-Z0-9\s,]{1,}$/",$Subject)) return true;
else return false;
}

function isHackerSafeCityState($Subject)
{
if( preg_match("/^[a-zA-Z\s]{1,}$/",$Subject)) return true;
else return false;
}
function isHackerSafeAnswer($Subject)
{
if( preg_match("/^[a-zA-Z0-9\s]{1,}$/",$Subject)) return true;
else return false;
}
function isHackerSafeQuestion($Subject)
{
if( preg_match("/^[a-zA-Z]{1,}$/",$Subject)) return true;
else return false;
}



?>


Thursday, June 14, 2007

Welcome to your Dream world ! ! !

Hi Guys ,

This is my test blog . To see how it looks .