So I have a function like this:
ra.reportConfigPage.CheckNumber = function (e, textbox)
var value = $(textbox).val();
var charCode = e.which ? e.which : event.keyCode;
var newValue = value + String.fromCharcode(charCode);
if (isNaN(newValue) || parseFloat(newValue) > maxValue)
So if it detects that if the new value is not a number or is greater than maxValue, it returns false, causing the event to stop propagating and the new character not to be entered.
The problem with this is that I'm assuming the new text value is [old text value] + [new character]. This is only the case when the carot is at the end of the text in the textbox. But what if the user has it at the begining or in the middle of the text. Or what if the user has some text highlighted, meaning that the new character being entered will replace the highlighted text. Or what if the user hit backspace? Or what if the user is pasting with Ctlr-v? The key stroke would be v, but the actual text entered into the textbox would be whatever's on the clipboard.
I'm wondering if there's a way to get the new textbox value from the event (or from anywhere). That way, I can just check the new value and that's it. Is there a way to do this?