So do what Peter said: Just clear all the contents of the text box and presto. You will be giving the user a blank field, again. Yes, with the cursor at the start.
*************
As for the ending NEWLINE character: Two ways.
(1) Using JavaScript, instead of trapping the key via ONKEYPRESS, try trapping it via ONKEYDOWN and then *cancelling* the ENTER key! That way, it won't even end up in the field.
(2) Using C#, just wipe out the last one or two characters of the string. (You'll need to check to see if the ENTER key put just "\n" on the end of the text [Unix style] or "\r\n" [Windows style].)
Lots of ways to do that using the various string class functions. Just look up the .NET docs for the String class.
http://msdn.microsoft.com/en-us/library/system.string_members(VS.80).aspx
Huh. I didn't even know this method existed! Look how easy they have made it for you:
http://msdn.microsoft.com/en-us/library/system.string.trimend(VS.80).aspx
|