Set focus on a text box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear All,
I have developed a aspx web page with c# as page language. I have place two
text boxes and two requiredfield validator control for each text box. Now
whenever i a text box is null, i want to set the focus on the text box apart
from displaying the error message. Please help.

Regards,
Swami
 
One way is to handle the onBlur event of the text box:

<asp:TextBox runat="server" id="txt" onblur="if (this.value.replace(/\s/g,
'').length == 0) this.focus();">

Dear All,
I have developed a aspx web page with c# as page language. I have place two
text boxes and two requiredfield validator control for each text box. Now
whenever i a text box is null, i want to set the focus on the text box apart
from displaying the error message. Please help.

Regards,
Swami
 
Back
Top