2011-08-27 71 views

回答

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>