<form name=form1 method="post" action="">
<input name="atc_desc1" type="text" size="6" maxlength="4">
<input name="atc_desc2" type="text" size="6" maxlength="4">
<input name="atc_desc3" type="text" size="6" maxlength="4">
<input name="atc_desc4" type="text" size="6" maxlength="4">
<input name="button1" type="button" value="提交" onclick="check()">
</form>
<script language=javascript>
function check()
{
Array.prototype.unique = function()
{
var a = {}; for(var i=0; i<this.length; i++)
{
if(typeof a[this[i]] == "undefined")
a[this[i]] = 1;
}
this.length = 0;
for(var i in a)
this[this.length] = i;
return this;
} if(form1.atc_desc1.value=="")
{
alert("1必须填写");
return false;
}
var a=new Array()
a.push(form1.atc_desc1.value)
if(form1.atc_desc2.value!="")
{
a.push(form1.atc_desc2.value)
}
if(form1.atc_desc3.value!="")
{
a.push(form1.atc_desc3.value)
}
if(form1.atc_desc4.value!="")
{
a.push(form1.atc_desc4.value)
}
if(a.length!=a.unique().length)
{
alert("有重复")
}
else
{
alert("ok")
}
}
</script>
<input name="atc_desc1" type="text" size="6" maxlength="4">
<input name="atc_desc2" type="text" size="6" maxlength="4">
<input name="atc_desc3" type="text" size="6" maxlength="4">
<input name="atc_desc4" type="text" size="6" maxlength="4">
<input name="button1" type="button" value="提交" onclick="check()">
</form>
<script language=javascript>
function check()
{
Array.prototype.unique = function()
{
var a = {}; for(var i=0; i<this.length; i++)
{
if(typeof a[this[i]] == "undefined")
a[this[i]] = 1;
}
this.length = 0;
for(var i in a)
this[this.length] = i;
return this;
} if(form1.atc_desc1.value=="")
{
alert("1必须填写");
return false;
}
var a=new Array()
a.push(form1.atc_desc1.value)
if(form1.atc_desc2.value!="")
{
a.push(form1.atc_desc2.value)
}
if(form1.atc_desc3.value!="")
{
a.push(form1.atc_desc3.value)
}
if(form1.atc_desc4.value!="")
{
a.push(form1.atc_desc4.value)
}
if(a.length!=a.unique().length)
{
alert("有重复")
}
else
{
alert("ok")
}
}
</script>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货