Wednesday, February 9, 2011

JS Code for Form Validation in Normal mode



function validation()
{
***************************** Name Validatation ***************************************
var name = document.frm1.empname.value;
var len =name.length;
if(name=="")
{
alert("Plz enter the name ");
flag=false;
return false;
}
if(document.frm1.empname.value!="" || document.frm1.empname.value!=null)
{
var a1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ";
for(i = 0; i=30)
{
alert("Your name to lang plz do not enter more then 30 digit");
flag=false;
return false;
}

//**********************************Department Validation************************

 

if (document.frm1.empdept.options[0].selected == true)
{
alert("Please select from the drop-down list.\n");
return false;
}
 

//***************************************Cantact*****************************************
 

var contact = document.frm1.empmob.value;
var conlen =contact.length;
if(contact=="")
{
alert("Plz Enter the mobile number");
flag=false;
return false;
}
if(document.frm1.empmob.value!="" || document.frm1.empmob.value!=null)
{
var a1 = "0123456789";
for(i = 0; i< 10) { alert("plz enter atleast 10 digit"); flag=false; return false; } 




//*****************************Date of Joining ***************************** 


var flag = true; var doj =document.frm1.empdoj.value; var now=new Date(); var today = new Date(now.getYear(),now.getMonth(),now.getDate()); if(doj=="" || doj==null) { alert("insert value in date "); flag = false; return false; } if (Date.parse(doj) > Date.parse(today)) {
alert("Invalid Date Range date must be less then current date");
return false;
}


}

No comments:

Post a Comment