WEB开发网
开发学院网页设计JavaScript 基于prototype.js验证框架(validation.js)的三个应... 阅读

基于prototype.js验证框架(validation.js)的三个应用

 2010-09-14 13:21:50 来源:WEB开发网   
核心提示: html代码:<formmethod=postaction=""id="frmRegister"><tablealign="center"style="height:100%"><

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}); 
}

上一页  1 2 3 4 5 

Tags:基于 prototype js

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接