function emailvalidation(entered, alertbox)
{
// Checking if the content has the general syntax of an email.
// Optional parameters are: 
// text--text that will show in an alertbox if content is illegal.
with (entered)
{
apos=value.indexOf("@"); 
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) 
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
}

function valuevalidation(entered, min, max, alertbox, datatype)
{
// Checking if the content is a number in a limited area.
// Optional parameters are:
// min --minimum value allowed in the field.
// max --maximum value allowed in the field.
// text --text that will show in an alertbox if content is illegal.
// type --enter "I" if only integers are allowed.
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
}
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function digitvalidation(entered, min, max, alertbox, datatype)
{
// Checking if the content has a certain number of digits.
// Optional parameters are:
// min --minimum number of digits allowed in the field.
// max --maximum number of digits allowed in the field.
// text --text that will show in an alertbox if content is illegal.
// type --enter "I" if only integers are allowed.
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") 
{checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
}
if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function emptyvalidation(entered, alertbox)
{
// Checking if the field is empty.
// Optional parameters are:
// text --text that will show in an alertbox if content is illegal.
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}
