到目前为止,这是我的代码,当我点击第一个文本框并将其留空时,边框颜色变为红色,并提示我它是空的,但是当我去我的其他区域时,将其留空,它仍然提示我,我的第一个文本框是空的而不是第二个文本框,如果我在第一个文本框上放置一个值,那么当边框颜色变为绿色时,它也是我提示第二个输入的时间是空的,我希望它像雅虎邮件注册中那样连续完成,请帮助
<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>
答案 0 :(得分: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>
试试这个......