rewrote defaults with $.fn.validatebox.defaults .
Usage
$('#vv').validatebox({
required:true
});
Validation rules
Validation rules are defined by using the required and validType attributes. Here are the rules that have been implemented:
email: Matches email regular expression rule
url: Match URL regular expression rules
length[0,100]: allow characters from x to y
remote['http://.../action.do','paramName']: send an ajax request to verify Value, returns 'true' on success.
To customize validation rules, override $.fn.validatebox.defaults.rules to define a validation function and invalid information. For example, define a minLength validation type:
$.extend( $.fn.validatebox.defaults.rules, {
minLength: {
validator: function(value, param){
return value.length >= param[0];
},
message: 'Please enter at least {0} characters.'
}
});
Now you can use this minLength validation type to define a minimum input of 5 characters Character input box:
特性
名称 |
类型 |
说明 |
默认值 |
required |
boolean |
定义是否字段应被输入。 |
false |
validType |
string |
定义字段的验证类型,比如 email、url,等等。 |
null |
missingMessage |
string |
当文本框是空时出现的提示文字。 |
This field is required. |
invalidMessage |
string |
当文本框的内容无效时出现的提示文字。 |
null |
方法
名称 |
参数 |
说明 |
destroy |
none |
移除并且销毁这个组件。 |
validate |
none |
进行验证以判定文本框的内容是否有效。 |
isValid |
none |
Call validate method and return the verification result, true or false. |