Archive for March, 2013

Form Validation using java script

Posted: March 10, 2013 in interview


form validtion
// <![CDATA[
function check()
{
valid=true;
if(document.fr.name.value=="")
{
alert("blank data data cant be inserted");
valid=false;
}
var x=document.fr.email.value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos=x.length)
{
alert("Not a valid e-mail address");
valid= false;
}
if((document.fr.g[0].checked==false)&&(document.fr.g[1].checked==false))
{
alert("select gender");
valid=false;
}
if(document.fr.edu.selectedIndex==0)
{
alert("select edu");
valid=false;
}
if(document.fr.msg.value=="")
{
alert("put the mesage");
valid=false;
}
}
// ]]>
//

// <![CDATA[
function isInteger(s)
{
var i;
s = s.toString();
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if (isNaN(c))
{
alert("R U stupid! This is not a number");
return false;
}

}
return true;

if(s.length

FORM VALIDATION

Name
email
MOB
Sex Male
Female
Education Select DegreeMPHSgraduateMAPHD
Hobby Cricket Footbal Reading BOOK
Message
Advertisements