How to compare if string has a enter key in the end using jquery/javascript?
Posted
by user144842
on Stack Overflow
See other posts from Stack Overflow
or by user144842
Published on 2010-04-15T13:36:20Z
Indexed on
2010/04/15
14:03 UTC
Read the original article
Hit count: 244
I have a string value from a user input box. I have to figure out if last char is a enter key (line feed).
Thats the code. Here I am checking if last char has a whitespace. Now I also have to check if last char is enter key (carriage return or line feed). How can i do this?
var txt = $get("<%= txtUserText.ClientID %>");
if (txt.value.substring(txt.value.length -1) !== ' ' || <checkifLastCharIsEnterKey>)
//my code to take action
**I don't think i need a keypress or keyup event because this above piece of code is not invoked at the time of user input.
© Stack Overflow or respective owner