I have a text input where if the entry is alpha, an ajax routine ensues. If the text entry is numeric I want to avoid the ajax routine and run a different (non-ajax) routine, but ONLY if the Enter key is used. I'm having a rough time trying to figure out if there's an Enter at the end of the input string.
The following doesn't work:
thisVal=$(this).val(); // the user input value
endChar = thisVal.charCodeAt( thisVal.substr(thisVal.length) )
if (!isNaN(thisVal) && endhCar == 13){
//Do the non-ajax routine
}
I've also tried thisVal.substr(-1). Same result. How do I code to get the enter key used or not? Help will be appreciated.