kendo grid输入框验证方法
$("#grid").kendoGrid({
dataSource: dataSrc,
//toolbar: ["save", "取消"],
columns: [
{
width: 70,
title: "請購承辦",
template: '#= ""+ask_man+"" #'
},
{
width: 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 != '\b') && (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
總結
以上是生活随笔為你收集整理的kendo grid输入框验证方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C 函数
- 下一篇: iOS一次定位解决方案(基于高德iOS