Hi
I would like to restrict entries of certain characters into a numeric text box, and I am doing it by handling the clientside Keypress event and cancelling the event in the JS function if the keypressed was one that I do not want to allow. This works great and user cannot type in the disallowed characters. (I am restricting the negative sign and the decimal point sign - see code snippet below).
Question I have is when users press a disallowed character, I would like the numeric text box to display the same visual effect as it does when users type in say an alphabet (which is not allowed on the numeric textbox).
In the case of typing in alphabets, the input box gets a red border and an image of a yellow triangle with an '!' is displayed in the control.
How can I achieve this UI effect when I filter out additional characters using custom javascript.
FYI - here's my JS handler that rejects the negative sign and decimal point.
Thanks
I would like to restrict entries of certain characters into a numeric text box, and I am doing it by handling the clientside Keypress event and cancelling the event in the JS function if the keypressed was one that I do not want to allow. This works great and user cannot type in the disallowed characters. (I am restricting the negative sign and the decimal point sign - see code snippet below).
Question I have is when users press a disallowed character, I would like the numeric text box to display the same visual effect as it does when users type in say an alphabet (which is not allowed on the numeric textbox).
In the case of typing in alphabets, the input box gets a red border and an image of a yellow triangle with an '!' is displayed in the control.
How can I achieve this UI effect when I filter out additional characters using custom javascript.
FYI - here's my JS handler that rejects the negative sign and decimal point.
_allowPositiveIntegersOnly =
function
(sender, args) {
/* Cancel the keystroke if it is a negativesign or a decimal separator */
var
keyCharacter = args.get_keyCharacter();
if
(keyCharacter == sender.get_numberFormat().DecimalSeparator ||
keyCharacter == sender.get_numberFormat().NegativeSign) {
args.set_cancel(
true
);
}
};
Thanks