Posted by: james | August 10, 2009

Important Javascript…

Mail ID Validation thriugh Regular Expression…

if(document.getElementById(‘mail’).value == ”)
{
alert(“Please Enter E-mail Id”);
document.reg.mail.focus();
return false;
}
else
{
var val = document.getElementById(‘mail’).value;
var patt1 = new RegExp(“^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+.([a-zA-Z]{2,4})$”);
if(patt1.test(val))
{
}
else
{
alert(“Please Enter Valid E-mail id”);
document.reg.mail.focus();
return false;
}
}

Check Box Selection:

function checkall()
{
var selectall = document.getElementById(‘selectall’);

var inputs = document.getElementsByTagName(‘input’);
//var checkboxes = [];
for(var i=0;i<inputs.length;i++)
{
if(inputs[i].type == ‘checkbox’)
{
if(selectall.checked == true)
{
inputs[i].checked = true;
}
else
{
inputs[i].checked = false;
}
}
}
}

function unselect()
{
var selectall = document.getElementById(‘selectall’);

var inputs = document.getElementsByTagName(‘input’);
var checkboxs = [];
for(var i=0;i<inputs.length;i++)
{
if(inputs[i].type == ‘checkbox’)
{
if(inputs[i].checked == false)
{
selectall.checked = false;
}
else
{
selectall.checked = true;
}
}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: