扩展combobox.defaults.rules
2.在combobox的data-options里加上validType
但是,你得在提交页面的时候进行页面验证。
jQuery 简介
jQuery 是一个 JavaScript 函数库。
jQuery 库包含以下特性:
1.HTML 元素选取
2.HTML 元素操作
3.CSS 操作
4.HTML 事件函数
5.JavaScript 特效和动画
6.HTML DOM 遍历和修改
7.AJAX
8.Utilities
jQuery实例
$(document).ready(function(){
$("button").click(function(){
$("p").hide();
});
});
This is a paragraph.
This is another paragraph.
扩展combobox.defaults.rules
if ($.fn.combobox) {
$.extend($.fn.combobox.defaults.rules, {
exist: {
validator: function (value, param) {
var $ctrl = $(this).parent().prev()
var opts = $ctrl.combobox('options');
var condition = new Object();
condition[opts.textField] = value;
return $ctrl.combobox('getData').getRecordsByFields(condition).length == 1;
},
message: 'Invalid country name.'
}
});
}
/*
options: 过滤条件 object类型
eg: {id: 123, name: 'piano'}
*/
Array.prototype.getRecordsByFields = function (options) {
var result = this.slice(0);
for (var f in options) {
result = $.grep(result, function (value, index) {
return value[f] == options[f];
});
}
return result;
}
2. 在combobox的data-options里加上validType
就可以解决你的问题。
但是,你得在提交页面的时候进行页面验证
if (!$dv.form("validate")) {
alert("Fill in the pink field.");
return;
}
希望现在还能帮到你。就算帮不到,让其它需要的人看一下也好哈。
如果只有一个需要验证的 input 的话:
$("input[class='easyui-validatebox']")[0].att('id')
如果有多个需要验证的 input 的话你是拿不到的,因为你的 input 中的数据太少了,最起码要有区别于其他 input 的属性
为什么要拿到 id 呢? id 一般是没有实际意义的 ,那只是一个标识,主要用来获取元素的,表示非常不理解 LZ 的意图