基于prototype.js验证框架(validation.js)的三个应用
2010-09-14 13:21:50 来源:WEB开发网html代码:
<formmethod=postaction=""id="frmRegister">
<tablealign="center"style="height:100%">
<tr>
<td>
<fieldsetstyle="padding:10px">
<legend>Register</legend>
<table>
<tr>
<tdclass="label">*SAPID</td>
<td><inputtype="text"name="sapId"id="sapId"class="required"></td>
</tr>
<tr>
<tdclass="label">*Password</td>
<td><inputtype="password"name="password"id="password"class="required"></td>
</tr>
<tr>
<tdclass="label">*Re-Password</td>
<td><inputtype="password"name="repassword"id="repassword"class="validate-identical"></td>
</tr>
<tr>
<tdcolspan="2"align="center"><inputtype="submit"class="submit"value="Register"></td>
</tr>
</table>
</fieldset>
</td>
</tr>
</table>
</form>
javascript脚本:
window.onload=function(){
//添加password一致性验证
Validation.add("validate-identical","thevalueofpasswordandrepasswordmustbeidentical",function(v){
return!Validation.get(’IsEmpty’).test(v)&&v==$F("password");
}) //验证器注册
varvalidator=newValidation(’frmRegister’,{stopOnFirst:true,immediate:true});
}
更多精彩
赞助商链接