با سلام اين كد چند تا تكس باكس رو چك مي كنه
[code:1]
<script Language="JavaScript" Type="text/javascript"><!--
function check(theForm)
{
if (theForm.name.value == "")
{
alert("Please enter a value for the "name" field.");
theForm.name.focus();
return (false);
}
if (theForm.lname.value == "")
{
alert("Please enter a value for the "lname" field.");
theForm.lname.focus();
return (false);
}
if (theForm.email.value == "")
{
alert("Please enter a value for the "email" field.");
theForm.email.focus();
return (false);
}
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊ
ËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäå
æçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789-.@";
var checkmail=""
var checkStr = theForm.email.value;
var allValid = true;
var validGroups = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
for (j = 0; j < checkOK.length; j++)
if (j == checkOK.length)
{
allValid = false;
break;
}
}
allValid = false;
checkmail="@";
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
if (ch == checkmail){
allValid = true;
break;}
}
allValid = false;
checkmail=".";
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
if (ch == checkmail)
if (i!=checkStr.length-1){
allValid = true;
break;}
}
checkmail=",";
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
if (ch == checkmail)
if (i!=checkStr.length-1){
allValid = false;
break;}
}
if (!allValid)
{
alert("Please enter email like this "
[email protected]".");
theForm.email.focus();
return (false);
}
var checkOK = "0123456789-";
var checkStr = theForm.tel.value;
var allValid = true;
var validGroups = true;
var decPoints = 0;
var allNum = "";
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
if (ch == ",")
{
allNum += ".";
decPoints++;
}
else
allNum += ch;
}
if (!allValid)
{
alert("Please enter only digit characters in the "tel" field.");
theForm.tel.focus();
return (false);
}
if (decPoints > 1 || !validGroups)
{
alert("Please enter a valid number in the "tel" field.");
theForm.tel.focus();
return (false);
}
return (true);
}
//--></script>
nobody[/code:1]