2011-08-27 6 views
0

が、私は、この画像のようにツールチップでjqueryのエラーを表示したい属性: http://www.position-relative.net/creation/formValidator/demos/demoValidators.html http://validity.thatscaptaintoyou.com/表示エラーは

しかし、彼らはasp.net MVC 3.0の検証属性で動作するように設計されていません。 そのようなプラグインはありますか?またはツールチップにそのようなエラーを表示するために何かできることはありますか?

答えて

1

Jquery検証プラグインを使用して、これと同様のことを行っています。このためには、最初にポップアップdivを作成する必要があります。

のJavascriptのFn

$("#formID").validate({ 
     submitHandler: function (form) { 
      CallFunction(); 
     }, 

     highlight: function (element, errorClass) { 
      HidePopup(element); 
      ShowPopup(element); 
     }, 

     unhighlight: function (element, errorClass) { 
      HidePopup(element); 
     }, 

     errorElement: "span", 

     errorPlacement: function (error, element) { 
      error.appendTo(element.prev("label")); 
     }, 

     rules: { 
      txtName:"required" 
     } 
}); 

function ShowPopup(paramElement) 
{ 
    //function to show popup and position div accordingly 
    $('#div'+paramElement.Id).show(); 
} 

function HidePopup(paramElement) 
{ 
    //function to hide popup 
    $('#div'+paramElement.Id).hide(); 
} 



**Html** 


<form id="formID" action=""> 

    <input name="txtName" type="text" id="txtName" /> 
    <div id="divtxtName" >Please enter name</div> 

</form> 
関連する問題