<input name=text1><input name=text2>
<script>
text1.value="kkdfa,jjadf,8888"
text2.value="4290=f,8888,dfasasdf,adsfasfd"
alert("现在验正");
alert(check(text1.value,text2.value))
function check(str1,str2){
var arr1=str1.split(",")
var arr2=str2.split(",")
for(i=0;i<arr1.length;i++)
for(j=0;j<arr2.length;j++)
if(arr1[i]==arr2[j]){alert("Error:"+arr1[i]);return false}
return true;
}
</script>

解决方案 »

  1.   

    第二种
    <input name=text1><input name=text2>
    <script>
    text1.value="kkdfa,jjadf,8888"
    text2.value="4290=f,8888,dfasasdf,adsfasfd"
    alert("现在验正");
    alert(check(text1.value,text2.value))
    function check(str1,str2){
    var arr1=str1.match(/[^,]+/g)
    var arr2=str2.match(/[^,]+/g)
    for(i=0;i<arr1.length;i++)
    for(j=0;j<arr2.length;j++)
    if(arr1[i]==arr2[j]){alert("Error:"+arr1[i]);return false}
    return true;
    }
    </script>
      

  2.   

    第三种
    <input name=text1><input name=text2>
    <script>
    text1.value="kkdfa,jjadf,8888"
    text2.value="4290=f,8888,dfasasdf,adsfasfd"
    alert("现在验正");
    alert(check(text1.value,text2.value))
    function check(str1,str2){
    var arr1=str1.match(/[^,]+/g)
    for(i=0;i<arr1.length;i++)
    if(new RegExp("(^|,)"+arr1[i]+"($|,)").test(str2)){alert("Error:"+arr1[i]);return false}
    return true;
    }
    </script>