sdnxiaotao 2017-02-07
<input type="text" pattern="[A-Z0-9_]{4}" class="k-input k-textbox" name="userId" required="required" data-bind="value:userId" data-required-msg="{{UserId}}{{required}}" validationMessage="编码字符只能是大写字母,数值或下滑线中的字符!" >
1.pattern="[A-Z0-9_]{4}"
2.validationMessage="编码字符只能是大写字母,数值或下滑线中的字符!"
另外一种:
$scope.dataSource = new kendo.data.DataSource({
batch: true,
transport: {
read: {
url: $rootScope.serviceRoot+"/user/read",
dataType: "json",
type: "POST",
contentType: "application/json"
},
create: {
url: $rootScope.serviceRoot+"/user/create",
dataType: "json",
type: "POST",
contentType: "application/json"
},
update: {
url: $rootScope.serviceRoot+"/user/update",
dataType: "json",
type: "POST",
contentType: "application/json"
},
destroy: {
url: $rootScope.serviceRoot+"/user/destroy",
dataType: "json",
type: "POST",
contentType: "application/json"
},
parameterMap:function(options, operation) {
if (operation !== "read" && options.models) {
//console.log("options.models:")
//console.log(options.models);
return JSON.stringify(options.models[0]);
// return {models: kendo.stringify(options.models)};
}
}
},
schema: {
model: {
id: "id",
fields: {
id: { from: "id", type: "number" },
userId: { from: "userId",
validation:
{
required: true,
useridvalidation: function (input) {
if (input.is("[name='userId']") && input.val() != "") {
input.attr("data-useridvalidation-msg", "编码字符只能是字母,数值或下 滑线中的5个字符!");
return /^[a-zA-Z0-9_]{5}$/.test(input.val());
}
return true;
},
validationMessage:$scope.UserId+$scope.required
}
},
userName:
{ from: "userName",
validation: {
required:true,
validationMessage:$scope.UserName+$scope.required }},
email:{from:"email"},
roleId:{from:"roleId"},
telNo:{from:"telNo"},
doctorId:{from:"doctorId",type:"number"},
locale:{from:"locale"},
password:{from:"password"}
}
}
}
});