Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
147573 | Sep 16,2019 12:33 PM UTC | Sep 19,2019 11:01 AM UTC | jQuery | 5 |
![]() |
Tags: ejMaskEdit |
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); |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.