How to show error message using jquery tooltip?

I am validating my controls on a form ... if the control is empty, I would like to show a jquery prompt with this msg error .. Here is what I do ...

if (document.getElementById("ctl00_ContentPlaceHolder1_ListDiscipline")
    .selectedIndex == -1) 
{
  document.getElementById("ctl00_ContentPlaceHolder1_ErrorMsg").innerHTML = 
      "please select your Discipline";
  document.getElementById("ctl00_ContentPlaceHolder1_ListDiscipline").focus();
  return false;
}

      

and I would like to do this,

if (document.getElementById("ctl00_ContentPlaceHolder1_ListDiscipline")
    .selectedIndex == -1) 
{
  // show tooltip besides the control with the error message...
  document.getElementById("ctl00_ContentPlaceHolder1_ListDiscipline").focus();
  return false;
}

      

Any suggestion...

+2


a source to share


1 answer


Here you will find some useful plugins for creating tooltips with jQuery

For example, when installing qTip, you can do something like this:



if (document.getElementById("ctl00_ContentPlaceHolder1_ListDiscipline")
.selectedIndex == -1) 
{
  $('#ctl00_ContentPlaceHolder1_ListDiscipline').qtip(
  {
    content: "please select your Discipline"
  });
  document.getElementById("ctl00_ContentPlaceHolder1_ListDiscipline").focus();
  return false;
}

      

+4


a source







All Articles