2012-07-12 4 views
2

에 대한 손실 포커스 이벤트에이 같은 자바 스크립트 기능이 있습니다자바 스크립트 탭 아웃

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "watermark", "function WaterMark(txtWaterMark, event, text) {if(event.type == 'keyup') {var charCode; if (event.charCode) { charCode = event.charCode;} else { charCode = event.keyCode; } if(charCode == 9 && txtWaterMark.value.length == 0) txtWaterMark.value = 'Pakistan';} if (txtWaterMark.value.length > 0 && event.type == 'mouseover') { txtWaterMark.style.color = '#c6c1c1'; } if (txtWaterMark.value.length > 0 && event.type == 'mouseout') { txtWaterMark.style.color = 'gray';} if (txtWaterMark.value.length == 0 && event.type == 'mouseout') {txtWaterMark.value = text; } if (event.type == 'focus') {txtWaterMark.style.color = 'gray'; if (txtWaterMark.value == text) { txtWaterMark.value = ''; } }}", true); 

을 나는 이런 식으로 호출 오전 :

<asp:TextBox ID="txtFirstName" runat="server" Width="110px" Text="First Name." 
       ForeColor="Gray" onmouseover="WaterMark(this, event,'First Name.');" onmouseout="WaterMark(this, event,'First Name.');" 
       onfocus="WaterMark(this, event,'First Name.');" onkeyup="WaterMark(this, event,'First Name.');" ToolTip="First Name." 
       ValidationGroup="CheckoutConfirm"></asp:TextBox> 

내가의 keyup 이벤트에 사용하고있는 경우 있도록 사용자가 Tab 키를 눌러 텍스트 상자 사이를 이동하면 텍스트 상자에 텍스트가 추가되지만 Tab 키를 누르면 텍스트 상자 안에 포커스가있을 때 키를 누르면 해고됩니다. 나는 '잃어버린 초점'과 같은 이벤트를 원한다.

답변

관련 문제