Jquery ValidateEngine表单验证


用法:http://www.position-relative.net/creation/formValidator/demoValidators.html

1.页面中引入js jquery.js, jquery.validateEngine.js

2.在需要验证的表单上写class类   如 class=”validate[required]”,可用的验证属性:

validate[required]

validate[required,custom[url]]

validate[required,equals[password]]

validate[required,funcCall[checkHELLO]]:验证时调用自定义函数 checkHELLO

     function checkHELLO(field, rules, i, options){

      if (field.val() != "HELLO") {

      // this allows to use i18 for the error msgs

     return options.allrules.validate2fields.alertText;

      }

     }

validate[required,minSize[6]]

validate[required,maxSize[6]]

validate[required,custom[integer],min[-5]]

validate[required,custom[integer],max[50]]

validate[custom[date],past[2010/01/01]]

validate[custom[date],future[NOW]]

validate[custom[]]

 

date

An ISO date, YYYY-MM-DD

number

Floating points with an optional sign. ie. -143.22 or .77 but also +234,23

integer

Integers with an optional sign. ie. -635 +2201 738

ipv4

An IP address (v4) ie. 127.0.0.1

onlyNumberSp

Only numbers and spaces characters

onlyLetterSp

Only letters and space characters

onlyLetterNumber

3.验证 在document.onload中执行 $("#formID").validationEngine();

4.判断是否验证通过 jQuery('#formID').validationEngine('validate'),返回为bool值


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM