function disallowCharacters(strText)
{
//The parameter to the function is the string which is to be validated
//The variable "strNotAllowed" below this line should contain the characters
// which are not allowed in the string
var strNotAllowed = ";:/\,&\\";
var checkStr = strText;
var allValid = true;
for (i = 0; i < strNotAllowed.length; i++)
{
if (strText.indexOf(strNotAllowed.charAt(i)) > 0)
{
allValid = false;
}
}
return allValid;
}
//----------------------------------
//how to use
if (document.Form1.txtemail.value!="")
{
//alert(disallowCharacters(document.Form1.txtemail.value));
if (!disallowCharacters(document.Form1.txtemail.value))
{
//alert('Invalid Character');
alert("Please enter a valid Email Address");
document.Form1.txtemail.focus();
return false;
}
else
{
bemail1=new RegExp(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/);
bemail2 = bemail1.exec(document.Form1.txtemail.value);
if(!bemail2)
{
alert("Please enter a valid Email Address");
document.Form1.txtemail.focus();
return false;
}
}
}
Sunday, December 10, 2006
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment