keyPress: function (args) {
var value = args.value;
// Regex Expression.
var reg = /^\d{0,3}(\.\d{0,1})?$/;
if (ej.isNullOrUndefined(value)) value = "";
// Enter the character based on cursor position.
var position = args.originalArgs.currentTarget.selectionStart;
value = value.substring(0, position) + String.fromCharCode(args.keyCode) + value.substring(position);
if (!(reg.test(value))) {
// Prevent the character does not match with regular expression.
args.originalArgs.originalEvent.preventDefault();
}
}, |
// Enter the character based on cursor position.
var startIndex = args.originalArgs.currentTarget.selectionStart;
var endIndex = args.originalArgs.currentTarget.selectionEnd;
value = value.substring(0, startIndex) + String.fromCharCode(args.keyCode) + value.substring(endIndex); |