0

I have a textbox and a button. I need to imitate the hover property for a textbox (if textbox value is empty) on button click.

I've tried the following, but it doesn't work:

HTML

<input id="surname" type="text" runat="server" />
<button id="Button1" runat="server" type="submit" onserverclick="RegistrationBtn_Click">OK</button>

Script

 function MakeHover() {
     $("#surname").mouseenter();
 }

C#

if (surname.Value == "")
  ScriptManager.RegisterStartupScript(this, this.GetType(), "Hover", "MakeHover();", true);
Rick Smith
  • 9,031
  • 15
  • 81
  • 85
Ksenia
  • 23
  • 1
  • 1
  • 6
  • I'm afraid this doesnt make a lot of sense. You want to make the mouse hover over the text box when its not there? Or is it that you want to dynamically add the `OnHover` event to your page? – crthompson May 06 '15 at 20:09
  • @paqogomez yes, you are right. I want to make the mouse hover over the text box when its not there – Ksenia May 06 '15 at 20:11
  • Pretty sure that would be a big security problem. Check out [these](http://stackoverflow.com/questions/4752501/move-the-mouse-pointer-to-a-specific-position) [two](http://stackoverflow.com/questions/2322603/move-mouse-pointer-in-javascript) answers. – crthompson May 06 '15 at 20:14

0 Answers0