Chinaunix首页 | 论坛 | 博客
  • 博客访问: 266634
  • 博文数量: 34
  • 博客积分: 569
  • 博客等级: 中士
  • 技术积分: 380
  • 用 户 组: 普通用户
  • 注册时间: 2012-05-10 14:10
文章分类

全部博文(34)

文章存档

2016年(6)

2014年(1)

2013年(5)

2012年(22)

我的朋友

分类: 系统运维

2012-08-22 16:12:55

转自

addMethod( name, method, [message] )Add a custom validation method. It must consist of a name (must be a legal javascript identifier), a javascript based function and a default string message.The arguments to the callback are:

* the current value of the validated element

* the element to be validated

* parameters specified for the method,e.g. for min: 5 the parameter is 5, for range: [1, 5] its [1, 5]

Please note: While the temptation is great to add a regex method that checks it's parameter against the value, it is much cleaner to encapsulate those regular expressions inside their own method. If you need lots of slightly different expressions, try to extract a common parameter.

A library of regular expressions:

Arguments:


name
The name of the method, used to identify and referencing it, must be a valid javascript identifier
method
The actual method implementation, returning true if an element is valid. First argument: Current value. Second argument: Validated element. Third argument: Parameters.
message(Optional),

The default message to display for this method. Can be a function created by jQuery.validator.format(value). When undefined, an already existing message is used (handy for localization), otherwise the field-specific messages have to be defined.

阅读(2133) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~