搜索文章:

首页  |  Java技术  |  Asp.net  |  Asp编程  |  VC/C++  |  Delphi  |  VB编程

表单数据自动提醒

<script language="javascript">
<!--
var formname = 'form1';
function checkinput(formid,preg,errormsg)
{

var val=document.all[formname][formid].value;
var rx = new regexp(preg);
var matches = rx.exec(val);
if (matches == null){
document.all[formname][formid].value='';
alert(errormsg);
}
}

function checkempty(formid,preg,errormsg)
{
if (
document.all[formname].id.value!=''
document.all[formname].id2.value!=''
document.all[formname].pw.value!=''
document.all[formname].em.value!=''
)
{
document.all[formname].btsubmit.disabled = false;
}

}
//-->
</script>
<form method=post action="" name="form1">

id :<input type="text" name="id" class="button" onchange="checkinput('id','^[a-za-z0-9_]{6,12}$','用户名 6-12位,其后只能含有字母、数字和下划线!')">
<br>

id2 :<input type="text" name="id2" class="button" onchange="checkinput('id2','^[a-za-z][a-za-z0-9_]+$','用户名首字符必须是字母,其后只能含有字母、数字和下划线!')">
<br>

pw :<input type="text" name="pw" class="button" onchange="checkinput('pw','.{6,16}','只能为密码为6~12位!')">
<br>

em :<input type="text" name="em" class="button" onchange="checkinput('em','^[_a-z0-9]+@([_a-z0-9]+\.)+[a-z0-9]{2,3}$','请输入正确的邮箱地址!')"><br>
<input type="text" validator="^(1920)[0-9]{2}$" errorinfo="不正确的年份!" >
<input type="button" name="btcheck" value="检测表单" onclick="checkempty()">
<input type="submit" name="btsubmit" value="提交表单" disabled>
</form>
相关文章:
© 2006   www.java-asp.net