Thursday, October 11, 2007

Monday, October 8, 2007

How the word 'Interface' came into OOP terminology

I thought of framing the question as (why the name for Interface is interface in Object Oriented Programming) :-). What ever, Just keep OOP aside and think what is an 'interface'?. What is the interface to your home/room/office?.

Interface is nothing but the way an object get exposed to the external world. That means you can play around with any object by its interface only. Now come to OOPs. U can play around with an object/class using its variables and its methods only(Is it Not?). Therefore interface to(of) a class is nothing but a its(class's) variables and method signatures.

Now come to Interface in OOPs..Afterall interface is also a class but it just consist only the variables and method signatures. Hence A class which just contains the details of its interface is called Interface.



JavaScript Email Validation

function validate_Email()
{
// Author: Surendra Sambana
//Purpose: Email validation using java script
// One can improve this using regular expressions.
var strEmail = document.getElementById('EmailId Field');
var len = strEmail.length;
var i_at = strEmail.indexOf("@");
var i_dot = strEmail.indexOf(".");
var i_space = strEmail.indexOf(" ");

if(len < 5) //a@b.c minimum length
{
alert("please enter your E-mail address");
strEmail.focus();
}
else if(i_at<=0 || i_dot<=0 || i_space!=-1 || i_dot==i_at+1 || i_dot==len-1 || i_at==len-1)
{
alert("please enter a valid Email ID");
strEmail.focus();
}
}

JavaScript Numeric field Validation

function validate_Numeric()
{
//Author: Surendra Sambana
//Purpose: This function validates a Numeric field
var num = document.getElementById('Numeri Field ID');
var len = num.length;
var i = 0;
while(i< len)
{
i++;
if(num.charAt(i)<=0 || str.charAt(i)>=9)
{
alert("Please enter a valid numeric");
}
}
}

JavaScript Convert Char to Ascii

function ToAscii(characher)
{
//Author: Surendra Sambana
//Purpose: This function returns Ascii value of a given char.
var counter;
for (counter = 0; counter< 256; ++ counter)
{
var to_hexa = counter.toString (16);
if (to_hexa . length == 1)
to_hexa = "0" + to_hexa;
to_hexa = "%" + to_hexa;
to_hexa = unescape (to_hexa);
if (to_hexa == characher)
break;
}
return counter;
}

JavaScript Alpha Numetric field Validation

function Validate_AlphaNumeric()
{
//Author: Surendra Sambana
var strToValidate = '*';
var j=0;

while(j < strToValidate.length)
{
if((97 <= ToAscii(strToValidate.charAt(j)))&&(ToAscii(strToValidate.charAt(j)) <= 122) || (ToAscii(strToValidate.charAt(j)) >= 48)&&(ToAscii(strToValidate.charAt(j)) < 57))
{
// Please change If statement if u want to eliminate else part
}
else
{
alert("please enter a valid Alpha Numeric value");
break;
}
j++;
}
}

JavaScript Required Field Validation

function Validate_RequiredField()
{
//Author : Surendra Sambana
var fieldToValidate = " ";
if(fieldToValidate.Trim() == null || fieldToValidate.Trim().length < 1)
alert("Please enter value")

alert(fieldToValidate.Trim().length );
}