Showing
1 changed file
with
13 additions
and
3 deletions
@@ -208,7 +208,6 @@ edit.prototype={ | @@ -208,7 +208,6 @@ edit.prototype={ | ||
208 | 208 | ||
209 | $("input:text",that.el) | 209 | $("input:text",that.el) |
210 | .add("input[type=number]",that.el) | 210 | .add("input[type=number]",that.el) |
211 | - | ||
212 | .add("input:hidden",that.el) | 211 | .add("input:hidden",that.el) |
213 | .add("textarea",that.el) | 212 | .add("textarea",that.el) |
214 | .each(function() { | 213 | .each(function() { |
@@ -220,7 +219,7 @@ edit.prototype={ | @@ -220,7 +219,7 @@ edit.prototype={ | ||
220 | var name=$(this).attr("placeholder")&&!(/^\d+$/.test($(this).attr("placeholder")))?$(this).attr("placeholder").replace(/请填写/g,''):$(this).parents(".form-group").find("label").text().replace(/\*/g,''); | 219 | var name=$(this).attr("placeholder")&&!(/^\d+$/.test($(this).attr("placeholder")))?$(this).attr("placeholder").replace(/请填写/g,''):$(this).parents(".form-group").find("label").text().replace(/\*/g,''); |
221 | // var rule = []; | 220 | // var rule = []; |
222 | 221 | ||
223 | - if ($(this).attr("required")) { | 222 | + if (id&&$(this).attr("required")) { |
224 | new Validator.init(document.getElementById(id),{ | 223 | new Validator.init(document.getElementById(id),{ |
225 | rules:{required:true} | 224 | rules:{required:true} |
226 | }).validate(function(obj){ | 225 | }).validate(function(obj){ |
@@ -246,14 +245,25 @@ edit.prototype={ | @@ -246,14 +245,25 @@ edit.prototype={ | ||
246 | 245 | ||
247 | }); | 246 | }); |
248 | 247 | ||
248 | + //文件上传 | ||
249 | $("input[type=file]",that.el).each(function(){ | 249 | $("input[type=file]",that.el).each(function(){ |
250 | var id = $(this).attr("id"); | 250 | var id = $(this).attr("id"); |
251 | var value =$.trim($(this).attr("value")); | 251 | var value =$.trim($(this).attr("value")); |
252 | var name=$(this).attr("placeholder")&&!(/^\d+$/.test($(this).attr("placeholder")))?$(this).attr("placeholder").replace(/请填写/g,''):$(this).parents(".form-group").find("label").text().replace(/\*/g,''); | 252 | var name=$(this).attr("placeholder")&&!(/^\d+$/.test($(this).attr("placeholder")))?$(this).attr("placeholder").replace(/请填写/g,''):$(this).parents(".form-group").find("label").text().replace(/\*/g,''); |
253 | - if ($(this).attr("required")&&!value) { | 253 | + if (id&&$(this).attr("required")&&!value) { |
254 | err.push("<p>"+name+"不可为空</p>"); | 254 | err.push("<p>"+name+"不可为空</p>"); |
255 | } | 255 | } |
256 | }); | 256 | }); |
257 | + //下拉选择 | ||
258 | + $("select",that.el).each(function(){ | ||
259 | + var id = $(this).attr("id"); | ||
260 | + var value =$.trim($(this).val()); | ||
261 | + var name=$(this).attr("placeholder")&&!(/^\d+$/.test($(this).attr("placeholder")))?$(this).attr("placeholder").replace(/请填写/g,''):$(this).parents(".form-group").find("label").text().replace(/\*/g,''); | ||
262 | + | ||
263 | + if (id&&$(this).attr("required")&&+value==-1) { | ||
264 | + err.push("<p>请选择 "+name+"</p>"); | ||
265 | + } | ||
266 | + }); | ||
257 | 267 | ||
258 | // var v = Validator.make(data, rules); | 268 | // var v = Validator.make(data, rules); |
259 | // v.mergeAttribute(attributes); | 269 | // v.mergeAttribute(attributes); |
-
Please register or login to post a comment