这里我需要实现某个文本框在验证通过时,test按钮才为可用状态。
首先添加一个文本框和按钮。
- <input class="easyui-validatebox" id="inputTest" />
- <input type="button" id="buttonTest" value="disabled" />
- $('#inputTest').validatebox({
- required: true,
- validType: 'length5'
- });
- $.extend($.fn.validatebox.defaults.rules, {
- length5: {// 验证长度
- validator: function (value) {
- if (boolean = value.length == 5) {
- $("#buttonTest").removeAttr("disabled");//启用按钮
- return true;
- }
- else {
- $("#buttonTeat").attr({ "disabled": "disabled" });//禁用按钮
- return false;
- }
- },
- message: '输入长度需为5位'
- }
- });
这只是个引见,具体应用时可以有很多变化,希望能有帮助。