<input id="b1" type="button" value="同意(10)" disabled="disabled" /> <script type="text/javascript"> var t = 10; var aa = window.setInterval('a()', 1000); function a() { var b = document.getElementById('b1'); t--; if (t == 0) { window.clearInterval(aa); b.value = '同意'; b.removeAttribute('disabled'); return; } b.value = '同意(' + t + ')'; }; </script>
倒计时(同意)
<div> <div id="d"></div> <asp:Button ID="b1" runat="server" Text="点我变色" /> <asp:Button ID="b2" runat="server" Text="点我移动" /> <script type="text/javascript"> var list = new Array(); list[0] = 'green'; list[1] = 'blue'; list[2] = 'yellow'; list[3] = 'black'; list[4] = 'navy'; list[5] = '#e0e0e0'; var num = 0; document.getElementById('b1').onclick = function () { document.getElementById('d').style.backgroundColor = list[num]; num++; if (num == 6) { num = 0; } }; var timer1 = null; document.getElementById('b2').onclick = function () { //document.getElementById('d').style.left = document.getElementById('d').style.offsetleft + 10 + 'px'; timer1 = window.setInterval('aaa()', 20); }; function aaa() { var d = document.getElementById('d'); d.style.left = d.offsetLeft + 5 + 'px'; if (d.offsetLeft >= 200) { window.clearInterval(timer1); return; } }; </script> </div>
点击移动变色
密 码:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br /> <br /> 确认密码:<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <script type="text/javascript"> document.getElementById('TextBox1').cnkeyup = function () { var t2 = document.getElementById('TextBox2'); if (t.value == t2.value) { alert('正确'); } else { alert('错误'); } }; document.getElementById('TextBox2').cnkeyup = function () { var t1 = document.getElementById('TextBox1'); if (t1.value == t2.value) { alert('正确'); } else { alert('错误'); } }; </script>
注册时,JS验证密码是否正确