写了一个,试试下面的两种操作
1、什么都不输入,点提交
2、只输入第一个,点提交
<html> 
<head> 
<script>
function checkFormat(){
var tempValue = document.all.text1.value;
if(tempValue == ""){
myAlert("span1");
return false;
} tempValue = document.all.text2.value;
if(tempValue == ""){
myAlert("span2");
return false;
}
return true;
}var flag = false;
var counter = 0;
function myAlert(id){
flag = !flag;
counter++;
if(flag){
document.getElementById(id).style.border = "1px solid red";
}else{
document.getElementById(id).style.border = "none";
}
if(counter < 6){
setTimeout("myAlert('" + id + "');",500);
}
}
</script>
</head> 
<body> 
<form>
<span id="span1">
<input type="text" name="text1"/>
</span>
<span id="span2">
<input type="text" name="text2"/>
</span>
<input type="submit" onclick="counter=0;return checkFormat()" value="提交"/>
</form>
</body> 
</html>

解决方案 »

  1.   


    <html> 
    <head> 
    <style>
    .color1{
    border:1px solid red;
    }
    .color2{
    border:1px solid blue;
    }
    </style>
    <script type="text/javascript"> 
    function blinklink() 

    var o = document.getElementById('blink');if (o.className == 'color1'){
        o.className = 'color2'
    }else{
        o.className = 'color1'
    }timer=setTimeout("blinklink()",100) 

    function stoptimer() 

    clearTimeout(timer) 

    window.setTimeout("stoptimer()",1000);
    </script> 
    </head> 
    <body onload="blinklink()" > 
    <INPUT TYPE="text" id="blink" class='color1'></body> 
    </html>
      

  2.   

    就是用setTimeout()来实现,并设置色调