0

到目前为止,这是我的代码,当我单击第一个文本框并将其留空时,边框颜色变为红色,并提示我它是空的,但是当我转到另一个字段并将其留空时,它仍然提示我的第一个文本框是空的而不是第二个文本框,如果我在第一个文本框上放了一个值,那就是边框颜色变为绿色的时候,也是我提示我的第二个输入为空的时间,我希望它像雅虎邮件注册中的那样连续完成,请帮助

 <script type="text/javascript">
             function CheckBlank(txt) {
                 var policyno = document.getElementById('txtPolNo');
                 var issuanceoffice = document.getElementById('dropIssOff');
                 if (policyno.value == '')
                 {
                     document.getElementById('txtPolNo').style.border= "solid 3px red";
                     alert('Policy Number is Required');

                     return false;
                 }  
                 else if (issuanceoffice.value == 'Select') {
                     document.getElementById('dropIssOff').style.border = "solid 3px red";
                     alert('Please Select Issuance Office');

                     return false;
                 }
                 else {
                     document.getElementById('txtPolNo').style.border = "solid 3px green";
                     document.getElementById('dropIssOff').style.border = "solid 3px green";
                     return true;
                 }






             }
    </script>

4

1 回答 1

0
<script type="text/javascript">
         function CheckBlank(txt) {
             var policyno = document.getElementById('txtPolNo').value.trim();
             var issuanceoffice = document.getElementById('dropIssOff').selecteditem;
             if (policyno.value == '')
             {
                 document.getElementById('txtPolNo').style.border= "solid 3px red";
                 alert('Policy Number is Required');
                 document.getElementById('txtPolNo').focus();

                 return false;
             }  
             if (issuanceoffice.value == 'Select') {
                 document.getElementById('dropIssOff').style.border = "solid 3px red";
                 alert('Please Select Issuance Office');
                 document.getElementById('txtPolNo').focus();
                 return false;
             }
             if(policyno.value != '' && issuanceoffice.value != 'Select')
             {
                 document.getElementById('txtPolNo').style.border = "solid 3px green";
                 document.getElementById('dropIssOff').style.border = "solid 3px green";
                 return true;
             }






         }
</script>

尝试这个...

于 2013-10-14T09:22:19.073 回答