我有一个文本框,允许用户使用十进制值键入值。如何在文本框中设置只能输入2位小数。现在,用户可以键入2个以上的小数位。以下是文本框的代码:
return parent.apply(this, arguments)
对于文本框,在id = rgPayment上,我使用rangevalidator来验证该值。 代码如下:
// The constructor function for the new subclass is either defined by you
// (the "constructor" property in your `extend` definition), or defaulted
// by us to simply call the parent constructor.
if (protoProps && _.has(protoProps, 'constructor')) {
child = protoProps.constructor;
} else {
child = function(){
return parent.apply(this, arguments);
};
}
// Add static properties to the constructor function, if supplied.
_.extend(child, parent, staticProps);
// Set the prototype chain to inherit from `parent`, without calling
// `parent` constructor function.
var Surrogate = function() {
this.constructor = child;
};
Surrogate.prototype = parent.prototype;
child.prototype = new Surrogate;
谢谢
答案 0 :(得分:0)
您可以下载JQuery numeric mask plugin并在页面上添加它的参考。然后使用
$('[id*="txtPayment"]').numeric({ decimal : ".", negative : false, scale: 2 });