home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
202.53.64.216
/
202.53.64.216.tar
/
202.53.64.216
/
janahitha
/
func.js
< prev
next >
Wrap
Text File
|
2004-11-26
|
5KB
|
270 lines
function isempty(val)
{
flag = false;
if(val.value=="")
flag = true;
else
{
flag = true;
for(i=0;i<val.value.length;i++)
if(val.value.substr(i,1)!=" ") flag = false;
}
if(flag==true)
{
alert("Enter The Column Value");
return true;
}
else
return false;
}
function isurl(val)
{
theinput = val.value;
thelength = theinput.length;
if(thelength>0)
{
loc = 0;
for(i=0;i<thelength-2;i++)
{
thestr = theinput.substr(i,3);
if(thestr=="://") loc = i;
}
isnot = "`!@$^*(){}[]\|;',<>";
url = true;
if(loc==0) url = false;
for(i=0;i<thelength;i++)
for(j=0;j<isnot.length;j++)
if((theinput.substr(i,1)==isnot.substr(j,1))||(theinput.substr(i,1)=='"')) url = false;
if(url==true)
return true;
else
{
alert("Enter A Valid URL");
return false;
}
}
else
return true;
}
function isnum(val)
{
if(isempty(val))
return false;
num = true;
theinput = val.value;
theinput.replace(" ","");
thelength = theinput.length;
for(i=0;i<thelength;i++)
{
thechar = theinput.substring(i,i+1);
if(thechar<"0" || thechar>"9") num = false;
}
if(num==false)
{
alert(" Please Enter A Numeric Value...");
return false;
}
else
return true;
}
function ismoney(val)
{
var theinput = val.value;
var thelength = theinput.length;
var money = true;
if(isempty(val))
return false;
for(i=0;i<thelength;i++)
{
thechar = theinput.substr(i,1);
if((thechar<"0" || thechar>"9") && (thechar!=".")) money = false;
}
if(money==false)
{
alert("Enter A Valid Currency Value");
return false;
}
else
return true;
}
function ispin(val)
{
if(val.value=="")
return true;
var theinput = val.value;
var thelength = theinput.length;
var pincode = true;
if(thelength!=6)
pincode = false;
else
for(i=0;i<6;i++)
{
thechar=theinput.substring(i,i+1);
if(thechar<"0" || thechar>"9") pincode=false;
}
if(pincode==false)
{
alert("Not A Valid Pin Code...Enter A 6-digit Pin Code");
return false;
}
else
return true;
}
function iszip(val)
{
if(isempty(val))
return false;
var theinput = val.value;
var thelength = theinput.length;
var pincode = true;
if(thelength!=5)
pincode=false;
else
for(i=0;i<5;i++)
{
thechar = theinput.substring(i,i+1);
if(thechar<"0" || thechar>"9") pincode = false;
}
if(pincode==false)
{
alert("Not a valid Pin Code...Enter again");
return false;
}
else
return true;
}
function islogin(val)
{
if(isempty(val))
return false;
var theinput = val.value;
var thelength = theinput.length;
var login = true;
if(val.value=="")
return true;
else
{
if(thelength<6) login=false;
if(login==false)
{
alert("Minimum 6 characters are allowed...Enter again");
return false;
}
else
return true;
}
}
function isphone(val)
{
if(isempty(val))
return false;
theinput = val.value;
phonenumber = true;
for(i=0;i<theinput.length;i++)
{
thechar = theinput.substring(i,i+1);
if(thechar<"0" || thechar>"9")
{
if(thechar!=" " && thechar!="-" && thechar!="+") phonenumber=false;
}
}
if(phonenumber==false)
{
alert("Not a valid Phone Number...Enter again");
return false;
}
else
return true;
}
function isemail(val)
{
if(isempty(val))
return false;
theinput = val.value;
theemail = true;
thelength = theinput.length;
if(thelength<5) theemail = false;
for(i=0;i<thelength;i++)
{
thechar=theinput.substr(i,1).toUpperCase();
if(!(thechar>="A" && thechar<="Z"))
if(!(thechar>="0" && thechar<="9"))
if(thechar!="." && thechar!="@" && thechar!="_" && thechar!="-")
theemail = false;
}
atloc1 = 0; atloc2 = 0; decloc = 0;
atloc1 = theinput.indexOf("@");
atloc2 = theinput.lastIndexOf("@");
decloc = theinput.indexOf(".");
if(atloc1==0 || decloc==0 || atloc1!=atloc2 || Math.abs(atloc1-decloc)<2 || decloc==(thelength-1)) theemail = false;
if(theemail==false)
{
alert("Not A Valid E-mail Address...Enter Again");
return false;
}
else
return true;
}
function issame(val1,val2)
{
sameval=true;
theinput1 = val1.value;
theinput2 = val2.value;
thelength1 = theinput1.length;
thelength2 = theinput2.length;
if(thelength1!=thelength2)
sameval = false;
else
{
if(theinput1!=theinput2) sameval=false;
}
if(sameval==false)
{
alert("Invalid Password...Enter again");
return false;
}
else
return true;
}
function isccno(val)
{
if(!(isnum(val)))
return false;
isccnum = false;
total = 0;
theinput = val.value;
thelength = theinput.length;
for(i=thelength-1;i>=1;i-=2)
{
total = total + parseInt(theinput.substr(i,1),10);
tmp = parseInt(theinput.substr(i-1,1)) * 2;
if(tmp<10)
total += tmp;
else
total += (tmp%10)+((tmp-(tmp%10))/10);
}
if(thelength%2==1)
total += parseInt(theinput.substr(0,1));
if(total%10==0)
isccnum=true;
if(isccnum==false)
{
alert("Not a valid CC Number...Enter again");
return false;
}
else
return true;
}