...
|
...
|
@@ -18,7 +18,7 @@ $("button").click(function(){ |
|
|
})*/
|
|
|
|
|
|
var $=require('jquery');
|
|
|
var Validator = require('../util/validate');
|
|
|
var Validator = require('./validate');
|
|
|
require('./upload');
|
|
|
require('../util/datepicker');
|
|
|
require('../util/jquery.gritter');
|
...
|
...
|
@@ -200,6 +200,8 @@ edit.prototype={ |
|
|
var that=this;
|
|
|
var rules = {},data = {},attributes={};
|
|
|
|
|
|
var err=[];
|
|
|
|
|
|
$("input:text",that.el)
|
|
|
.add("input[type=number]",that.el)
|
|
|
.add("input[type=file]",that.el)
|
...
|
...
|
@@ -212,14 +214,16 @@ edit.prototype={ |
|
|
value=!!$(this).attr("value")?$(this).attr("value"):$(this).val();
|
|
|
}
|
|
|
var name=$(this).attr("placeholder")&&!(/^\d+$/.test($(this).attr("placeholder")))?$(this).attr("placeholder").replace(/请填写/g,''):$(this).parents(".form-group").find("label").text().replace(/\*/g,'');
|
|
|
var rule = [];
|
|
|
// var rule = [];
|
|
|
|
|
|
if ($(this).attr("required")) {
|
|
|
rule.push("required");
|
|
|
rules[id] = rule.join('|');
|
|
|
data[id] = value;
|
|
|
attributes[id]=name;
|
|
|
new Validator.init(document.getElementById(id),{
|
|
|
rules:{required:true}
|
|
|
}).validate(function(obj){
|
|
|
err.push("<p>"+name+"不可为空</p>");
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// if ($(this).attr("maxlength")) {
|
|
|
// rule.push("max:" + $(this).attr("maxlength"));
|
|
|
// }
|
...
|
...
|
@@ -238,13 +242,17 @@ edit.prototype={ |
|
|
|
|
|
});
|
|
|
|
|
|
var v = Validator.make(data, rules);
|
|
|
v.mergeAttribute(attributes);
|
|
|
var err=[];
|
|
|
if (v.fails()) {
|
|
|
for(var key in v.messages()){
|
|
|
err.push("<p>"+v.messages()[key]+"</p>");
|
|
|
}
|
|
|
// var v = Validator.make(data, rules);
|
|
|
// v.mergeAttribute(attributes);
|
|
|
// var err=[];
|
|
|
// if (v.fails()) {
|
|
|
// for(var key in v.messages()){
|
|
|
// err.push("<p>"+v.messages()[key]+"</p>");
|
|
|
// }
|
|
|
// that.__err(err.join(''));
|
|
|
// return false;
|
|
|
// }
|
|
|
if(err.length>0){
|
|
|
that.__err(err.join(''));
|
|
|
return false;
|
|
|
}
|
...
|
...
|
@@ -335,7 +343,8 @@ edit.ajaxfileupload=function(el,option){ |
|
|
'action': '/ajax/upload',
|
|
|
'params':$.extend({},{__type:"fileupload-upload"},option.params),
|
|
|
onComplete:option.onComplete,
|
|
|
onStart: option.onStart
|
|
|
onStart: option.onStart,
|
|
|
valid_extensions:["xlsx"]
|
|
|
})
|
|
|
}
|
|
|
edit.prototype.init.prototype=edit.prototype;
|
...
|
...
|
|