帮忙看看这个js错在哪里?
我是想要radio选中N的时候才提示的,现在情况是我没选中或选中Y都提示了,,错在哪里呀?
<script>function beforesubmit(){ if (document.getElementById("FixYN").value="N")//if (document.form1.FixYN.value ="N" ){ if (document.form1.BBPre.value!="") { var len1 = document.form1.BBPre.value.length //获取判定碼值的長度 var BBPre1 = document.form1.BBPre.value var beginno1 = document.form1.beginno.value //獲取beginno的值 var beginno2 = (beginno1.substr(0,len1)) if (BBPre1 != beginno2) {alert("首碼與判定碼不對應!")form1.beginno.focus();return false;}}}}</script><form id="form1" name="form1" method="post" action="" onsubmit="return beforesubmit()"> <p> <label for="BBPre"></label> <input name="BBPre" type="text" id="BBPre" value="ABCD" /> Y : <input type="radio" name="FixYN" id="FixYN" value="Y" /> N: <label for="FixYN"></label> <input type="radio" name="FixYN" id="FixYN" value="N" /> <label for="FixYN"></label> </p> <p> <label for="beginno"></label> <input type="text" name="beginno" id="beginno" /> </p> <p> <input type="submit" name="button" id="button" value="提交" /> </p></form><script>function beforesubmit(){ if (document.getElementById("FixY").checked)//if (document.form1.FixYN.value ="N" ){ if (document.form1.BBPre.value!="") { var len1 = document.form1.BBPre.value.length //获取判定碼值的長度 var BBPre1 = document.form1.BBPre.value var beginno1 = document.form1.beginno.value //獲取beginno的值 var beginno2 = (beginno1.substr(0,len1)) if (BBPre1 != beginno2) {alert("首碼與判定碼不對應!")form1.beginno.focus();return false;}}}}</script><form id="form1" name="form1" method="post" action="" onsubmit="return beforesubmit()"> <p> <label for="BBPre"></label> <input name="BBPre" type="text" id="BBPre" value="ABCD" /> Y : <input type="radio" name="FixYN" id="FixY" value="Y" /> N: <label for="FixYN"></label> <input type="radio" name="FixYN" id="FixN" value="N" /> <label for="FixYN"></label> </p> <p> <label for="beginno"></label> <input type="text" name="beginno" id="beginno" /> </p> <p> <input type="submit" name="button" id="button" value="提交" /> </p></form>