对输入框进行检测,通过就会在前面打勾表示通过

王朝other·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

有什么问题请到<a href='/bbs/forums.php?fid=21'>论坛</a>中发表<br>

<!--# 特效来源:http://www.webjx.com/js -->

<!--把如下代码加入<body>区域中-->

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

FormName = "form" //Name of the form

CheckName = "check" //Name of the checkboxes (without 1,2,3...10,11,12...)

TextName = "text" //Name of the textfields (without 1,2,3...10,11,12...)

var Condition=new Array(

'a!=""', //Must be filled

'a!=""', //Must be filled

'a!=""&&a.length>5&&a.indexOf("@")!=-1&&a.indexOf(".")!=-1', //Must be longer than 5 characters, have @, and atleast one '.'

'a.length>7&&!(a.split("/")[0]*1>12)&&!(a.split("/")[1]*1>31)&&!(a.split("/")[2]*1<1900)' //Must be longer than 7 characters, first (two) digit(s) NOT greater than 12, second (two) digit(s) NOT greater than 31 and last 4 greater than 1900

);

function docheck(w) {

eval("a=document." + FormName + "." + TextName + w + ".value");

if (eval(Condition[w])) eval("document." + FormName + "." + CheckName + w + ".checked=true");

else eval("document." + FormName + "." + CheckName + w + ".checked=false");

}

// End -->

</script>

<form name=form>

<input type=checkbox name=check0 onClick="return false"> First: <input type=text name=text0 onBlur='docheck("0")'><BR>

<input type=checkbox name=check1 onClick="return false"> Last: <input type=text name=text1 onBlur='docheck("1")'><BR>

<input type=checkbox name=check2 onClick="return false"> E-Mail: <input type=text name=text2 onBlur='docheck("2")'><BR>

<input type=checkbox name=check3 onClick="return false"> Birthday (mm/dd/yyyy): <input type=text name=text3 onBlur='docheck("3")'><BR>

</form>

[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航