日期:2014-05-16 浏览次数:20367 次
<FORM> 姓名: <INPUT TYPE="text" NAME="name"> <INPUT TYPE="button" VALUE="请单击" onClick=alert("谢谢你,"+this.form.name.value)> </FORM>
<Script> function getFocus(obj) { obj.style.color='red'; obj.style.background='#DBDBDB'; } function getBlur(obj) { obj.style.color='black'; obj.style.background='white'; } </Script> <BODY onLoad=document.form1.name.focus()> <FORM NAME="form1"> 姓 名:<INPUT TYPE="text" NAME="name" onFocus=getFocus(this) onBlur=getBlur(this)><BR> 电 话:<INPUT TYPE="text" NAME="tel" onFocus=getFocus(this) onBlur=getBlur(this)><BR> </FORM> </BODY>
<Script> var i = 0; function movenext(obj,i) { if(obj.value.length==4){ document.forms[0].elements[i+1].focus(); } } function result() { fm = document.forms[0]; num = fm.elements[0].value + fm.elements[1].value + fm.elements[2].value + fm.elements[3].value ; alert("你输入的信用卡号码是"+ num); } </Script> <BODY onLoad=document.forms[0].elements[i].focus()> 请输入你的信用卡号码: <form> <input type=text size=3 maxlength=4 onKeyup=movenext(this,0)> - <input type=text size=3 maxlength=4 onKeyup=movenext(this,1)> - <input type=text size=3 maxlength=4 onKeyup=movenext(this,2)> - <input type=text size=3 maxlength=4 onKeyup=movenext(this,3)> <input type=button value=显示 onClick=result()> </form> </BODY>
<Script> function checkPw() { fm = document.form1; if (fm.pw2.value != fm.pw1.value) { alert("密码不符,请重新输入"); document.form1.pw2.select(); } else alert("谢谢你,"+fm.name.value); } </Script> <BODY onLoad=document.form1.name.focus()> <FORM NAME="form1"> 姓 名:<INPUT TYPE="text" NAME="name"><BR> 输入密码:<INPUT TYPE="password" NAME="pw1"><BR> 重新输入:<INPUT TYPE="password" NAME="pw2"><BR> <INPUT TYPE="button" VALUE="填好了" onClick=checkPw()> <INPUT TYPE="reset" VALUE="重 填"> </FORM> </BODY>
<Script> function isInt(elm) { if (isNaN(elm)) { alert("你输入的是" + elm + "\n不是数字!"); document.forms[0].pw.value = ""; return false; } if (elm.length != 4) { alert("请输入四位数数字!"); document.forms[0].pw.value = ""; return false; } } </Script> <form action="test.asp" onSubmit="return isInt(this.pw.value)"> 请输入四位数数字密码:<BR> <input type="passw