views:

338

answers:

3

I have two textBoxes lets say EmailID and UserId. Currently when a user Types his/her EmailId the same gets shown in the UserID TextBox, for this I am using OnkeyDown event javascript.

The Issue That I am having is if the user copies the EmailId an Paste it in the EmailId textBox then the OnKeyDown event is not fired, is there any other Event that I need to capture or is there anyworkaround availabel for this.

A: 

Use the onchange event instead. That should work.

Me1000
onchange is not fired until the textbox is blurred.
Bryan
+1  A: 

There isn't any event that will work for all methods of changing a textbox's contents. A workaround would be to set an interval when the EmailId text box gets focus, and cancel it when EmailId is blurred. The interval could either check if the text has changed, or just copy EmailId's value into UserID.

Do you have to update UserID as they type? It would be cleaner to copy EmailId's value into UserId in EmailId's blur event.

Bryan
A: 

You could make it so that the user cannot type into the UserId box, make it readonly, so you can still update it.

Then, use an onblur on the email address box, and just copy whatever is there to the UserId box.

There shouldn't be any way to update the email address that doesn't fire the onblur event.

James Black