kendo grid输入框验证方法

$("#grid").kendoGrid({
dataSource: dataSrc,
//toolbar: ["save", "取消"],
columns: [
{
70,
title: "请购承办",
template: '#= ""+ask_man+"" #'
},
{
70,
title: "联系方式",
template: '#= ""+ask_man_contact+"" #'
}
],
change: function (e) {
//原产地、交货天数、制造厂商等字段如果有指定的值,则不能输入
set_input_disabled();
},
edit: function(e) {
  

//if (!e.model.isNew()) {
// Disable the editor of the "id" column when editing data items
//var numeric = e.container.find("input[name=unit_price]").data("kendoNumericTextBox");
var numeric = e.container.find("input[name=unit_price]");
numeric.keyup(function (k) {
if (/^[d.]?$/.test(k.char) == false && (k.char != '') && (k.key != 'Left') && (k.key != 'Right')) {
alert('请输入正确的金额!');
$(this).val('0');
return false;
}
});
numeric.blur(function () {
var unitprice = parseFloat(this.value);
var taxrate = parseFloat(/d+/.exec(e.container.next().html())[0]);
var oTaxRate = e.container.next().find('input[name="tax_rate"]');
if (oTaxRate && oTaxRate.length > 0) {
taxrate = parseFloat(oTaxRate.attr('aria-valuenow'));
}
var tax = unitprice * taxrate / 100;
e.container.next().next().html(tax);//税金
var num = parseInt(e.container.prev().prev().prev().html());//数量
e.container.next().next().next().html(num * unitprice);//总金额
});
var manufacturers = e.container.find("input[name=manufacturers]");
manufacturers.keypress(function () {
if (this.value != '') {
alert('制造厂商已指定,不能再修改!');
return false;
}
});
var country_of_origin = e.container.find("input[name=country_of_origin]");
country_of_origin.keypress(function () {
if (this.value != '') {
alert('原产地已指定,不能再修改!');
return false;
}
});


},
editable: true,
sortable: false,
pageable: false,
selectable: "multiple",
dataBound: function () {

}


});

原文地址:https://www.cnblogs.com/yuanxiaoping_21cn_com/p/3432362.html